Page 1 of 1

quick question

Posted: Sun Jan 15, 2012 11:16 pm
by rstinohio1
i wrote this to display user posts on a news feed type page, how would i be able to display only users with something in the post row of my database?
<div class="container">
	<?php
	$result = mysql_query("SELECT * FROM posting ORDER BY id");

		
	//foreach(fetch_users() as $users){
	//echo '{$users}';
	echo "<table border='0'>

<tr>

<th>UserName</th>

<th>Most Recent Post</th>

</tr>";

while($row = mysql_fetch_array($result))

 {

 echo "<tr>";

 echo "<td>" . $row['usr'] . "</td>";

 echo "<td>" . $row['post'] . "</td>";

 echo "</tr>";

 }

echo "</table>";		
	?>  
	</div>  

Re: quick question

Posted: Mon Jan 16, 2012 3:14 pm
by jacek
SELECT `columns`, `you`, `need` FROM `postings` WHERE `post_body` != '' ORDER BY `id`
I guess would work.

Why would you have empty posts in the table at all though ? :?

Re: quick question

Posted: Fri Jan 20, 2012 7:20 pm
by rstinohio1
Its like a user status box, some of them have it left blank so i dont want to show them as having a new status if they dont have one. im going to try your code now.

Re: quick question

Posted: Fri Jan 20, 2012 7:35 pm
by rstinohio1
thanks, i got it to work, i dont know why your full code didnt work, so i had to play around a bit. thanks!
<div id="main">


	<div class="container">
	<?php
	$result = mysql_query("SELECT * FROM posting WHERE `post` != '' ORDER BY id");

		
	//foreach(fetch_users() as $users){
	//echo '{$users}';
	echo "<table border='0'>

<tr>

<th>UserName</th>

<th>Most Recent Post</th>

</tr>";

while($row = mysql_fetch_array($result))

 {

 echo "<tr>";

 echo "<td>" . $row['usr'] . "</td>";

 echo "<td>" . $row['post'] . "</td>";

 echo "</tr>";

 }

echo "</table>";		
	?>  
	</div>    
</body>
</html>