PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!
I have a search box which takes a form and looks through the database for possible matches. I need an If statement to return an echo that the record was not found. I have attempted it at the bottom, but I get an error.
<?
mysql_connect("localhost","","");
mysql_select_db("audit");
$search=$_POST["search"];
$result = mysql_query("SELECT * FROM dedicated WHERE customer LIKE '%$search%'");
//grab all the content
while($r=mysql_fetch_array($result))
{
$asset=$r["asset"];
$customer=$r["customer"];
//display the row
if ($r=mysql_fetch_array ="") {
echo "No records found";
}
else {
echo "<tr><td><a href='viewall.php?varl=".$asset."'>".$asset."</a></td><td>".$customer."</td></tr> ";
}
?>
mysql_connect("localhost","","");
mysql_select_db("audit");
$search=$_POST["search"];
$result = mysql_query("SELECT * FROM dedicated WHERE customer LIKE '%$search%'");
//grab all the content
if (mysql_num_rows($result) == 0) {
echo "No records found";
} else {
while($r=mysql_fetch_array($result)) {
echo "<tr><td><a href='viewall.php?varl=".$r["asset"]."'>".$r["asset"]."</a></td><td>".$r["customer"]."</td></tr> ";
}
}