cdoggg94 Posted May 8, 2012 Share Posted May 8, 2012 Basically I want this to do do is: if (there is no result found in the query){ echo "nothing for this brand"; }else{ echo this link; } this is my code...im just confused on what i want the if statement to to ask for. any help would be greatly appreciated <?php $mypro = mysql_query("SELECT * FROM Sheet1 WHERE pro_catagory LIKE '%People%' ORDER BY pro_id DESC"); while($row=mysql_fetch_array($mypro)) { if(Not sure what to put here){ echo "There are no listings for the brand right now"; }else{ print "- <a href='proList.php?proNumber=".$row['pro_id']."'>".$row['pro_name']."</a><br />"; } } ?> Quote Link to comment https://forums.phpfreaks.com/topic/262260-re-no-result/ Share on other sites More sharing options...
Maq Posted May 8, 2012 Share Posted May 8, 2012 Use something like this: $mypro = mysql_query("SELECT * FROM Sheet1 WHERE pro_catagory LIKE '%People%' ORDER BY pro_id DESC"); if(mysql_num_rows($mypro) == 0) { echo "There are no listings for the brand right now"; } else { while($row = mysql_fetch_array($mypro)) { print "- ".$row['pro_name']." "; } } ?> Don't use * unless you really want to select every column. You also would want to add some proper error checking because there is a chance mysql_query could return "false" which would error out your program, read - http://www.phpfreaks.com/blog/or-die-must-die Quote Link to comment https://forums.phpfreaks.com/topic/262260-re-no-result/#findComment-1344012 Share on other sites More sharing options...
cdoggg94 Posted May 8, 2012 Author Share Posted May 8, 2012 Thanks a ton for the help and again for the advice..I am reading that page right now. Quote Link to comment https://forums.phpfreaks.com/topic/262260-re-no-result/#findComment-1344014 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.