tebrown Posted May 18, 2012 Share Posted May 18, 2012 Hey Guys, Im having problems with my code. What im trying to do is run a mysql query and show the results, but if the query returns no data, echo out "No incoming requests!" Here is my code: <? $check = "SELECT * FROM requests WHERE club='" . $_SESSION['club'] . "' AND team='" . $_SESSION['team'] . "' AND accepted='0'"; $result=mysql_query($check); if (mysql_num_rows($result) == 0) { while ($getinfo = mysql_fetch_array($result)) { $time = $getinfo["time"]; $who = $getinfo["player_name"]; $whofor = $getinfo["toplayfor"]; $from = $getinfo["team"]; $idp = $getinfo["player_id"]; echo "<a href='profile.php?id=".$idp."&team=".$from."'>".$who." </a><div style='float:right;'>(".$from.")</div><br />"; echo "<div style='margin-top: 2px;'></div>"; echo date('l, F jS, g:ia',$time); echo "<br /><div style='margin-top: 2px;'></div><a href='accept.php?playerid=".$idp."&toplayfor=".$whofor."'>Accept</a> | Decline"; echo "<div id='newsline'></div>"; } } else { echo 'No incoming requests'; } ?> Could someone help me out here? Thanks Heaps! Quote Link to comment https://forums.phpfreaks.com/topic/262715-mysql_query-help/ Share on other sites More sharing options...
creata.physics Posted May 18, 2012 Share Posted May 18, 2012 under $check, can you add: print_r($check); underneath, copy&paste the output into something like phpmyadmin, and see what the results are. it will give you the error if any. it will also help you determine if the session club and team are set. Quote Link to comment https://forums.phpfreaks.com/topic/262715-mysql_query-help/#findComment-1346507 Share on other sites More sharing options...
tebrown Posted May 18, 2012 Author Share Posted May 18, 2012 I've got the results i need, although if there a NO results, i want it to display the echo message. Quote Link to comment https://forums.phpfreaks.com/topic/262715-mysql_query-help/#findComment-1346508 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.