tylercaiden Posted November 13, 2007 Share Posted November 13, 2007 Hi! I would like to hide the rows where the "points" column is empty. I am ordering by points desc and half the users do not have points. $query = "select * from user ORDER BY `Points` DESC"; $result = mysql_query($query); while($row = mysql_fetch_assoc($result)) { $Html_Listp = $Html_Listp."<table width='84%' border='0' align='center' cellpadding='2' cellspacing='0'> <tr> <td width='4%'><input name='CHECKID' type='checkbox' class='title_list1' value='$id'></td> <td width='32%' class='title_list'>{$row['name']}</td> <td width='26%' class='title_list'>{$row['user']}</td> <td width='24%' class='title_list'>{$row['Points']}</td> <td width='14%' class='title_list'>{$row['id']}</td> </tr> </table>"; Quote Link to comment Share on other sites More sharing options...
bri0987 Posted November 13, 2007 Share Posted November 13, 2007 You could say something like: if ($row['Points'] == "") { // do something here } else { // do something else here } >> OR if your using NULL fields in your database << if ($row['Points'] == NULL) { // do something here } else { // do something else here } Quote Link to comment Share on other sites More sharing options...
bri0987 Posted November 13, 2007 Share Posted November 13, 2007 Also with your code... You do not have to keep your TABLE in PHP... you can go in and out of it as long as it's within php brackets Example: <?php while($row = mysql_fetch_assoc($result)) { $Html_Listp = $Html_Listp ?> <table width='84%' border='0' align='center' cellpadding='2' cellspacing='0'> <tr> <td width='4%'><input name="CHECKID" type='checkbox' class='title_list1' value='<?php echo $id; ?>'></td> <td width='32%' class='title_list'><?php echo $row['name']; ?></td> <td width='26%' class='title_list'><?php echo $row['user']; ?></td> <td width='24%' class='title_list'><?php echo $row['Points']; ?></td> <td width='14%' class='title_list'><?php echo $row['id']; ?></td> </tr> </table> <?php // end the while loop here. } ?> Also if you do it this way I would say to change the single quotes ( ' ) to double quotes ( " ) for html... Quote Link to comment Share on other sites More sharing options...
tylercaiden Posted November 13, 2007 Author Share Posted November 13, 2007 i think im doing this wrong, sorry im very new to php... i tried setting it up like this thinking it will print all rows greater than 0 but it only prints one row $query = "select * from user ORDER BY `Points` DESC"; $result = mysql_query($query); while($row = mysql_fetch_assoc($result)) if ($row['Points'] > 0) { $Html_Listp = "<table width='84%' border='0' align='center' cellpadding='2' cellspacing='0'> <tr> <td width='4%'><input name='CHECKID' type='checkbox' class='title_list1' value='$id'></td> <td width='32%' class='title_list'>{$row['name']}</td> <td width='26%' class='title_list'>{$row['user']}</td> <td width='24%' class='title_list'>{$row['Points']}</td> <td width='14%' class='title_list'>{$row['id']}</td> </tr> </table>"; } Quote Link to comment Share on other sites More sharing options...
Daukan Posted November 13, 2007 Share Posted November 13, 2007 maybe change your query to just get all with point > 0 $query = "select * from user WHERE `Points`>0 ORDER BY `Points` DESC"; Quote Link to comment Share on other sites More sharing options...
tylercaiden Posted November 13, 2007 Author Share Posted November 13, 2007 hey it worked Daukan! Thank you very much! Quote Link to comment 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.