anthonydamasco Posted August 9, 2006 Share Posted August 9, 2006 If PHP Search engine couldn't find anything, I want it to say something like "revise your search"this is the code i got[code=php:0]$search=$_POST["search"];$result = mysql_query("SELECT * FROM joborder WHERE companyname LIKE '%$search%'");while($r=mysql_fetch_array($result)){ $companyname=$r["companyname"]; $posdes=$r["positiondescription"]; $firstname=$r["firstname"]; $date=$r["date"]; $email=$r["email"]; $id=$r["orderid"]; $local=$r["nearestlocation"]; echo " $companyname";}?>[/code]I dont even know how to start to do this Link to comment https://forums.phpfreaks.com/topic/17028-if-php-search-engine-couldnt-find-anything/ Share on other sites More sharing options...
hostfreak Posted August 9, 2006 Share Posted August 9, 2006 http://php.net/ifandhttp://php.net/elseShould get you started. Link to comment https://forums.phpfreaks.com/topic/17028-if-php-search-engine-couldnt-find-anything/#findComment-71862 Share on other sites More sharing options...
anthonydamasco Posted August 9, 2006 Author Share Posted August 9, 2006 Well this is what I got so far, and It doesnt work, what am I doing wrong?[code=php:0]$search = "$month, $day, $year"];$result = mysql_query("SELECT * FROM joborder WHERE date LIKE '%$search%'");while($r=mysql_fetch_array($result)){ $companyname=$r["companyname"]; $posdes=$r["positiondescription"]; $firstname=$r["firstname"]; $date=$r["date"]; $email=$r["email"]; $id=$r["orderid"]; $local=$r["nearestlocation"];if (!$result){ echo "please revise your search" }else{ echo "<table width=\"600\" border=\"0\" cellspacing=\"0\" cellpadding=\"0\"> <tr> <td> </td> <td> </td> <td> </td> <td> </td> </tr> <tr> <td> </td> <td><div align=\"center\"><a href=\"rrform.php?id=$id\">Click here to view this form</a></div></td> <td> </td> <td> </td> </tr> <tr> <td width=\"44\"> </td> <td width=\"369\">$companyname</td> <td width=\"82\"><img src=\"images/order.jpg\" width=\"67\" height=\"23\"></td> <td width=\"105\">$id</td> </tr> <tr> <td> </td> <td>$firstname</td> <td><strong>Date</strong></td> <td><b>$date</b></td> </tr> <tr> <td> </td> <td><a href=\"$email\">$email</a></td> <td> </td> <td>$local</td> </tr> <tr> <td> </td> <td> </td> <td> </td> <td> </td> </tr> <tr> <td> </td> <td colspan=\"3\"><table width=\"100%\" border=\"0\" cellspacing=\"0\" cellpadding=\"0\"> <tr> <td>$posdes</td> <td> </td> </tr> <tr> <td width=\"72%\"> </td> <td width=\"28%\"> </td> </tr> </table></td> </tr></table>";}?>[/code] Link to comment https://forums.phpfreaks.com/topic/17028-if-php-search-engine-couldnt-find-anything/#findComment-71888 Share on other sites More sharing options...
alexruimy Posted August 9, 2006 Share Posted August 9, 2006 [code=php:0]$search=$_POST["search"];$result = mysql_query("SELECT * FROM joborder WHERE companyname LIKE '%$search%'");$num = mysql_num_rows($result);if ($num == "0"){echo "You needs to be revisin' yo search, fool.";}else {while($r=mysql_fetch_array($result)){ $companyname=$r["companyname"]; $posdes=$r["positiondescription"]; $firstname=$r["firstname"]; $date=$r["date"]; $email=$r["email"]; $id=$r["orderid"]; $local=$r["nearestlocation"]; echo " $companyname";}}[/code][hr]I imagine that may work. Link to comment https://forums.phpfreaks.com/topic/17028-if-php-search-engine-couldnt-find-anything/#findComment-71889 Share on other sites More sharing options...
anthonydamasco Posted August 9, 2006 Author Share Posted August 9, 2006 thnx man! you rawk! Link to comment https://forums.phpfreaks.com/topic/17028-if-php-search-engine-couldnt-find-anything/#findComment-71890 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.