Forums
This topic is locked
hide row if column empty
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."< tab le width='84%' border='0' align='center' cellpadding='2' cellspacing='0'>
< t r >
< t d width='4%'>< in p ut name='CHECKID' type='checkbox' class='title_list1' value='$id'></ td>
< t d width='32%' class='title_list'>{$row['name']}</ t d>
< t d width='26%' class='title_list'>{$row['user']}</ t d>
< t d width='24%' class='title_list'>{$row['Points']}</ t d>
< t d width='14%' class='title_list'>{$row['id']}</ t d>
< / t r >
< / ta ble>";
</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 >=1, something like this . . .
<pre id=code><font face=courier size=2 id=code> if( $row['Points']>=1{
// here put the code to print the table row
// in your example <tr> to </tr>
// 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
<pre id=code><font face=courier size=2 id=code> if( $row['Points']>=1{
// here put the code to print the table row
// in your example <tr> to </tr>
// 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