Page 1 of 1

did my select do anything....?

Posted: Sun Jun 09, 2002 11:53 pm
by chris12295
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>";

Posted: Mon Jun 10, 2002 3:38 am
by Wayne

Code: Select all

$num_rows = mysql_num_rows($result);

echo "Number of rows returned: ".$num_rows;