Jump to content


Photo

If PHP Search engine couldn't find anything....


  • This topic is locked This topic is locked
4 replies to this topic

#1 anthonydamasco

anthonydamasco
  • Members
  • PipPipPip
  • Advanced Member
  • 92 posts

Posted 09 August 2006 - 03:37 PM

If PHP Search engine couldn't find anything, I want it to say something like "revise your search"

this is the code i got

$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";
}
?>

I dont even know how to start to do this


#2 hostfreak

hostfreak
  • Members
  • PipPipPip
  • Advanced Member
  • 581 posts

Posted 09 August 2006 - 03:41 PM

http://php.net/if
and
http://php.net/else

Should get you started.

#3 anthonydamasco

anthonydamasco
  • Members
  • PipPipPip
  • Advanced Member
  • 92 posts

Posted 09 August 2006 - 04:30 PM

Well this is what I got so far, and It doesnt work, what am I doing wrong?

$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>&nbsp;</td>
    <td>&nbsp;</td>
    <td>&nbsp;</td>
    <td>&nbsp;</td>
  </tr>
  <tr>
    <td>&nbsp;</td>
    <td><div align=\"center\"><a href=\"rrform.php?id=$id\">Click here to view this form</a></div></td>
    <td>&nbsp;</td>
    <td>&nbsp;</td>
  </tr>
  <tr>
    <td width=\"44\">&nbsp;</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>&nbsp;</td>
    <td>$firstname</td>
    <td><strong>Date</strong></td>
    <td><b>$date</b></td>
  </tr>
  <tr>
    <td>&nbsp;</td>
    <td><a href=\"$email\">$email</a></td>
    <td>&nbsp;</td>
    <td>$local</td>
  </tr>
  <tr>
    <td>&nbsp;</td>
    <td>&nbsp;</td>
    <td>&nbsp;</td>
    <td>&nbsp;</td>
  </tr>
  <tr>
    <td>&nbsp;</td>
    <td colspan=\"3\"><table width=\"100%\" border=\"0\" cellspacing=\"0\" cellpadding=\"0\">
      <tr>
        <td>$posdes</td>
        <td>&nbsp;</td>
      </tr>
      <tr>
        <td width=\"72%\">&nbsp;</td>
        <td width=\"28%\">&nbsp;</td>
      </tr>
    </table></td>
  </tr>
</table>";
}
?>


#4 alexruimy

alexruimy
  • Members
  • PipPip
  • Member
  • 20 posts

Posted 09 August 2006 - 04:33 PM

$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";
}
}
 
I imagine that may work.

#5 anthonydamasco

anthonydamasco
  • Members
  • PipPipPip
  • Advanced Member
  • 92 posts

Posted 09 August 2006 - 04:39 PM

thnx man! you rawk!




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users