runnerjp Posted April 10, 2009 Share Posted April 10, 2009 i need to be able to display a message if a users has not posted anything in the forum.... im not sure how to get this right... here is my attempt <?php $sql = "Select * FROM forumtutorial_posts where author = '$profilename' ORDER BY `showtime` DESC LIMIT 0, 5"; $postsresult = mysql_query($sql) or die("Could not get threads"); while($row = mysql_fetch_assoc($postsresult)) { echo ' <a id="posts" href="http://www.runningprofiles.com/members/index.php?page=message&forum='.$row['forum'].'&id='.$row['postid'].'&pagenum=last">'.$row['title'].'</a> <br />' ;} [b]if ($postresults < 0)[/b] {echo 'user has yet to make a post.';}?> Link to comment https://forums.phpfreaks.com/topic/153479-solved-if-no-results-do-this/ Share on other sites More sharing options...
jackpf Posted April 10, 2009 Share Posted April 10, 2009 Something like so: if(mysql_num_rows($postresult) == 0) { echo 'You have not made a post...'; } Link to comment https://forums.phpfreaks.com/topic/153479-solved-if-no-results-do-this/#findComment-806392 Share on other sites More sharing options...
runnerjp Posted April 10, 2009 Author Share Posted April 10, 2009 i get Warning: mysql_num_rows(): supplied argument is not a valid MySQL result resource in /home/runningp/public_html/members/include/profile.php on line 139 user has yet to make a post. Link to comment https://forums.phpfreaks.com/topic/153479-solved-if-no-results-do-this/#findComment-806399 Share on other sites More sharing options...
mmarif4u Posted April 10, 2009 Share Posted April 10, 2009 Can you show us the updated code. Link to comment https://forums.phpfreaks.com/topic/153479-solved-if-no-results-do-this/#findComment-806408 Share on other sites More sharing options...
runnerjp Posted April 10, 2009 Author Share Posted April 10, 2009 completed it .... this is what i did! <?php $result = mysql_query("SELECT * FROM pb where uid='".$getuser['ID']."' Order by pb") or die(mysql_error()); $num2 = mysql_num_rows($result); if($num2 < 1) {echo 'what ever';} Link to comment https://forums.phpfreaks.com/topic/153479-solved-if-no-results-do-this/#findComment-806505 Share on other sites More sharing options...
jackpf Posted April 10, 2009 Share Posted April 10, 2009 Sick. Link to comment https://forums.phpfreaks.com/topic/153479-solved-if-no-results-do-this/#findComment-806523 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.