vicodin Posted March 14, 2008 Share Posted March 14, 2008 What i want to do is check if anything has retrieved from mysql or not. Any help would be appreciated. Current code: mysql_select_db("mediapil_mkmdata") or die(mysql_error()); $query = "SELECT * FROM products WHERE proid = $prodid"; $result = mysql_query($query) or die(mysql_error()); $row = mysql_fetch_array($result); echo ' Quote Link to comment Share on other sites More sharing options...
rhodesa Posted March 14, 2008 Share Posted March 14, 2008 like this? <?php mysql_select_db("mediapil_mkmdata") or die(mysql_error()); $query = "SELECT * FROM products WHERE proid = $prodid"; $result = mysql_query($query) or die(mysql_error()); if(mysql_num_rows($result)){ while($row = mysql_fetch_array($result)){ } }else{ echo "No rows found"; } ?> Quote Link to comment Share on other sites More sharing options...
vicodin Posted March 14, 2008 Author Share Posted March 14, 2008 No its only looking for one thing. If it doesnt find it then i want ti to echo something and if it finds it then echo the product. Quote Link to comment Share on other sites More sharing options...
p2grace Posted March 14, 2008 Share Posted March 14, 2008 Count the results before continuing <?php $query = "SELECT * FROM products WHERE proid = $prodid"; $result = mysql_query($query) or die(mysql_error()); $num = mysql_num_rows($result); if($num > 0){ // results found }else{ // no results found } ?> Quote Link to comment Share on other sites More sharing options...
vicodin Posted March 14, 2008 Author Share Posted March 14, 2008 Thank you worked perfect! Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.