beansandsausages Posted January 19, 2008 Share Posted January 19, 2008 hey, im not to good with mysql, i have the following code witch works fine // get some information from the data base. $sql = "SELECT * FROM `post_box` WHERE `read`='N' AND `name`='$name' "; $result = mysql_query($sql); if (!$result) { echo "Could not successfully run query ($sql) from DB: " . mysql_error(); exit; } if(mysql_num_rows($result) == 0) { echo "You have no new posts sorry."; include_once("bottom.php"); exit; } while ($row = mysql_fetch_assoc($result)) { { echo " Text here. "; } } mysql_free_result($result); what i want to try and do is the query $sql = "SELECT * FROM `post_box` WHERE `read`='N' AND `name`='$name' "; will some times bring several results back how would i show it say like this : You have [number] new posts. i have tried 1 or 2 ways and they just seem to kill the page doesnt load even after 10min or so. any help would be apriciated Quote Link to comment https://forums.phpfreaks.com/topic/86746-solved-not-so-good-with-mysql/ Share on other sites More sharing options...
asmith Posted January 19, 2008 Share Posted January 19, 2008 put this anywhere you want to show on page : echo 'you have'. mysql_num_rows($result).' new posts'; Quote Link to comment https://forums.phpfreaks.com/topic/86746-solved-not-so-good-with-mysql/#findComment-443339 Share on other sites More sharing options...
beansandsausages Posted January 19, 2008 Author Share Posted January 19, 2008 i have tried that all ready :'( but it works for you when you did it haha must of spelt num wrong * go checks error log * Haha i had echo " You have ".mysql_mum_rows($result)." new posts"; any way thanks Quote Link to comment https://forums.phpfreaks.com/topic/86746-solved-not-so-good-with-mysql/#findComment-443340 Share on other sites More sharing options...
asmith Posted January 19, 2008 Share Posted January 19, 2008 well you had to count the results rows , not the result's mother rows Quote Link to comment https://forums.phpfreaks.com/topic/86746-solved-not-so-good-with-mysql/#findComment-443341 Share on other sites More sharing options...
beansandsausages Posted January 19, 2008 Author Share Posted January 19, 2008 have no idea why did that but oh well haha its sorted now thanx Quote Link to comment https://forums.phpfreaks.com/topic/86746-solved-not-so-good-with-mysql/#findComment-443342 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.