Hi all..
I would like to check if the number of records is more than zero.
$sql = "SELECT count(*) FROM Hardware WHERE Location = '$location'";
how to continue from the above statement?
$sql = "SELECT count(*) FROM Hardware WHERE Location = '$location'"; $result = mysql_query($sql) or die("Query failed: $sql - " . mysql_error()); $row = mysql_fetch_array($result); echo "</p>There were {$row[0]} matches in the DB for $location.</p>\n";
Thanks for ur help
If you are grabbing the data and want a quick count of how many results you got look at mysql_num_rows
bike5 wrote:If you are grabbing the data and want a quick count of how many results you got look at mysql_num_rows
Which in this case would be 1.
Which should only be used if you want the data as well as the count. If you only want the count it's much better to use the SQL function count().