No Matches?
Senior Editor, TheScripts.com
Ok, believe it or not we just finished the first line of sub search_two.... and that was a lot of work. Now it gets to the easy stuff though, so no worries,
$search_num = @results;
Just as you might think its doing.... the number of values in @results is now being saved into $search_num. Just as a reminder, @results is the array &search returned its array, @search_results, into.
&nomatches if ($search_num < 1);
If there are less then 1 results, then just proceed to &nomatches.
&multi_match_view(@results) if ($search_num > 0);
Otherwise, if there are more then 0 results, go to the muli_match_view sub procedure.
Here is an explanation of that &nomatches sub below....
sub nomatches { my $colspan = @db_fields;
Saves into the scalar variable $colspan the number of values in @db_fields, and sets it as a my variable
&header("No Matches Found For ". $form{'search_term'});
Here we call the header sub procedure, and feed into it the title of the page, with the search term we were looking for included in the title. I didn't need to use the . (concatenation) operator here, but I find separating strings from variables makes it more readable.
print qq~
<CENTER><TABLE border=1 bgcolor="#FFFFFF" cellpadding=3
cellspacing=0>
<TR bgcolor="#C0C0C0">
~;
Normal HTML, as you can see.
foreach $field (@db_fields) {
print qq~<TD><CENTER><FONT size=-1>$field</CENTER></TD>~;
}
Here we make the Title bar of the table. It showcases all of the fields of the database in their own <TD> area.
print qq~</TR>
<TR bgcolor="#DDDDDD">
<TD colspan=~.$colspan.qq~><CENTER><FONT size=-1><B>No
Matches Found For "$form{'search_term'}"
</B></CENTER></TD></TR></TABLE></CENTER>
~;
Here we used that $colspan variable declared at the top. This is just used to center the text in the table, so it doesn't look funky. $form{'search_term'} is used here in quotes, no big deal.
&footer;
The footer is printed.
}
End of sub nomatches.
