Gossamer Forum
Home : Products : DBMan : Customization :

fix 1 Matches

Quote Reply
fix 1 Matches
I'm in the process of modifing dbman to match my site, and I came across a funny little problem within html_view_success.I'm using friendly html.pl.
When only 1 record is returned via search results, It returns "your search returned 1 Matches". It would be nice if it returned "Your search returned 1 match".
I tried my hand at a bit of code, but not knowing Pearl from a bar of soap, I got a syntax error.
This is what I tried,
if($db_total+hits)=1
{print" <center><$font>Your search returned <b>$db_total_hits</b> match.</font>" Wink else {print"<center><$font>Your search returned <b>$db_total_hits</b> matches.</font>";}
Hey don't laugh, I had a go, and you never know, I may just learn somthing.
I would also like to use somthing similar, using $db_total_hits to print a small graphic at the bottom of my search results near $db_next_hits if there are more than say 3 of 4 records returned, ie if $db_total_hits>3 print the graphic, else don't.
thanks heeps
bob
Quote Reply
Re: fix 1 Matches In reply to
You're really pretty close. I think you've done a very good job. Let's see if I can give you the nudge you need. (and I'll get rid of the little smiley face at the same time. Smile )

Code:
if($db_total_hits==1) {
print "<center><$font>Your search returned <b>$db_total_hits</b> match.</font>";
}
else {
print"<center><$font>Your search returned <b>$db_total_hits</b> matches.</font>";
}

You just had some parentheses in the wrong place and (the major thing) was that when you test for whether a variable is equal to something you need to use == for numbers and eq for text.

I try to think it terms of "is equal to" for comparisons and "equals" for assignment, so I don't forget to use the different syntax.

For your graphic, it would be similar:

Code:
if ($db_total_hits > 3) {
print graphic;
}


------------------
JPD