I ran a simple search in a database that decides if a keyword matches a word in a column using PHP. How can i print a message if a result was not found? i dont know how to determine if there was a result or not. please help. here is my code so far:
mysql_connect("localhost");
mysql_select_db("Ads");
$query = "select * from user_Ads where model like '$keywords'";
$result = mysql_query($query);
$number_cols = mysql_num_fields($result);
while ($row = mysql_fetch_row($result)) {
echo "<table border=1>\n";
echo "<tr align=left>\n";
for($i=0;$i<$number_cols;$i++){
echo "<td>";
if(!isset($row[$i])) {
echo "N/A";
}
else {
echo $row[$i];
}
echo "</td>\n";
}
echo "</tr>\n";
}
echo "</table>";
did my select do anything....?
Moderator: General Moderators
-
chris12295
- Forum Contributor
- Posts: 113
- Joined: Sun Jun 09, 2002 10:28 pm
- Location: USA
- Contact:
Code: Select all
$num_rows = mysql_num_rows($result);
echo "Number of rows returned: ".$num_rows;