I needed to have a products page displayed for each product returned by
the script, instead of
a table where each line is one record. Below is where I simply moved the
statements to
print the fields. The numbers in $fields[0] refer to the numbers
corresponding to the field
named at the beginning of the setup file. The script is being used at
http://egifts.cen-trex.com/
Maybe someone else can use this, maybe they can't...
#################################################################
# search_results_body Subroutine #
#################################################################
sub search_results_body
{
# Notice that in this subroutine we have access to the
# $total_row_count hits variable if we want to display it.
print qq~
Your Search Turned Up
$total_row_count
Items...
~;
# Basically, we will display a simple HTML table to show
# all of the rows which satisfied the search criteria
# entered by the user.
#
# The idea is this. We will go through the @database_rows
# (which was given to us by db-lib.pl and contains all of
# the hits) one element at a time and convert the pipe
# delimited database row into an HTML row.
foreach $row (@database_rows)
{
@fields = split (/\|/, $row);
# Of course, we will only actually display fields which we
# have defined as displayable in @db_index_for_display and
# we will be careful to convert all pipe symbols and new
# lines from our db representation values into their
# original forms.
foreach $index (@db_index_for_display)
{
$fields[$index] =~ s/~p~/\|/g;
$fields[$index] =~ s/~nl~/\n/g;
# Also, we will check to see if the current field being
# displayed happens to be an email field. If so, we will
# make it a clickable mailto link.
#
# Notice that you would use the exact same method for
# making a clickable URL.
if ($index == $index_for_email)
{
print qq~
$fields[$index] | \n ~;
}
else
{
}
} # End of foreach $index (@db_index_for_display)
print "#$fields[0]
- $fields[1]
\n";
print "\n";
print "| $fields[8] |
\n";
print "$fields[2] \n";
print "\n";
print "| Category | Weight | Suggested
Retail | eGifts
Price | \n";
print "\n";
print "| $fields[10] | $fields[3] | \$
$fields[4] | \$
$fields[6] | \n";
print " \n";
print "  | /n";
print "
\n";
print "
\n";
print "\n";
}
}