...

View Full Version : select returns nothing?



andrew1234
08-31-2009, 07:13 PM
Hi

How do I check if my SELECT statment returns nothing. then it must echo "returns nothing";

Because right now if the customer_ID doesn't exist it wont echo anything.

Thanks






$sql_search_users = "SELECT * FROM customers_for_store WHERE customer_ID = $_X ";


$result = mysql_query($sql_search_users, $con_connect) or die('Error: '.mysql_error());



while ($row = mysql_fetch_array($result)) {

echo "<br /><br />".$row['customer_ID']." ".$row['first_name']." ".$row['last_name']." ".$row['credits_left']." ".$row['date_joined'].".<br /><br />";

}

ohgod
08-31-2009, 07:21 PM
http://us.php.net/manual/en/function.mysql-num-rows.php


if(mysql_num_rows($result) < 1){ echo 'No rows returned';}else{do other stuff;}

andrew1234
08-31-2009, 07:32 PM
Thank you....



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum