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>"; Link to comment https://forums.phpfreaks.com/topic/77068-solved-hide-row-if-column-empty/ 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 } Link to comment https://forums.phpfreaks.com/topic/77068-solved-hide-row-if-column-empty/#findComment-390289 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... Link to comment https://forums.phpfreaks.com/topic/77068-solved-hide-row-if-column-empty/#findComment-390295 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>"; } Link to comment https://forums.phpfreaks.com/topic/77068-solved-hide-row-if-column-empty/#findComment-390315 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"; Link to comment https://forums.phpfreaks.com/topic/77068-solved-hide-row-if-column-empty/#findComment-390329 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! Link to comment https://forums.phpfreaks.com/topic/77068-solved-hide-row-if-column-empty/#findComment-390332 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.