Get ready for BLACK FRIDAY shopping starting in

Forums

PHP

This topic is locked

hide row if column empty

Posted 13 Nov 2007 01:39:13
1
has voted
13 Nov 2007 01:39:13 tyler mr posted:
how would i hide the rows when they have no points? right now half the users have zero points and i would rather not show them in the list.

<pre id=code><font face=courier size=2 id=code>

$query = "select * from user ORDER BY `Points` DESC";
$result = mysql_query($query);

while($row = mysql_fetch_assoc($result))
{

$Html_Listp = $Html_Listp."&lt; tab le width='84%' border='0' align='center' cellpadding='2' cellspacing='0'&gt;
&lt; t r &gt;
&lt; t d width='4%'&gt;&lt; in p ut name='CHECKID' type='checkbox' class='title_list1' value='$id'&gt;&lt;/ td&gt;
&lt; t d width='32%' class='title_list'&gt;{$row['name']}&lt;/ t d&gt;
&lt; t d width='26%' class='title_list'&gt;{$row['user']}&lt;/ t d&gt;
&lt; t d width='24%' class='title_list'&gt;{$row['Points']}&lt;/ t d&gt;
&lt; t d width='14%' class='title_list'&gt;{$row['id']}&lt;/ t d&gt;
&lt; / t r &gt;
&lt; / ta ble&gt;";

</font id=code></pre id=code>

Replies

Replied 16 Nov 2007 16:04:14
16 Nov 2007 16:04:14 Alan C replied:
one way to handle it would be to test the value of point before 'printing' the row and only sending the row if &gt;=1, something like this . . .

<pre id=code><font face=courier size=2 id=code> if( $row['Points']&gt;=1{


// here put the code to print the table row
// in your example &lt;tr&gt; to &lt;/tr&gt;
// so the row only gets generated when there are points to show

}

</font id=code></pre id=code>

you may also need something that enables users to see all the rows because if they don't have points then they will not see themselves

Reply to this topic