twilitegxa Posted August 23, 2009 Share Posted August 23, 2009 I have the following code: $display_block .= "</table></td> <td width=50% valign=top> <table> <tr> <td><h1>Attribute/Sub-Attribute Notes</h1></td></tr> <tr> <td> <ol>"; //gather attributes and sub-attributes notes $get_sub_notes = "select notes from scout_sub_attributes where identity = '$identity'"; $get_sub_notes_res = mysql_query($get_sub_notes, $conn) or die(mysql_error()); while ($sub_notes_info = mysql_fetch_array($get_sub_notes_res)) { $sub_notes = $sub_notes_info['notes']; $display_block.= " <li>$sub_notes</li>"; } $display_block .= "</ol></table></td></tr></table>"; How can I only display the records from the database in this list that have a value? There are several empty values in the table, and I don't want to display these in the list. Can I use an if statement, or is there some other way?[/code] Link to comment https://forums.phpfreaks.com/topic/171474-solved-not-display-records-that-are-blank/ Share on other sites More sharing options...
Fog Juice Posted August 23, 2009 Share Posted August 23, 2009 I have the following code: $display_block .= "</table></td> <td width=50% valign=top> <table> <tr> <td><h1>Attribute/Sub-Attribute Notes</h1></td></tr> <tr> <td> <ol>"; //gather attributes and sub-attributes notes $get_sub_notes = "select notes from scout_sub_attributes where identity = '$identity'"; $get_sub_notes_res = mysql_query($get_sub_notes, $conn) or die(mysql_error()); while ($sub_notes_info = mysql_fetch_array($get_sub_notes_res)) { $sub_notes = $sub_notes_info['notes']; $display_block.= " <li>$sub_notes</li>"; } $display_block .= "</ol></table></td></tr></table>"; How can I only display the records from the database in this list that have a value? There are several empty values in the table, and I don't want to display these in the list. Can I use an if statement, or is there some other way?[/code] Could you add something like "select notes from scout_sub_attributes where identity = '$identity' and notes IS NOT NULL"? Link to comment https://forums.phpfreaks.com/topic/171474-solved-not-display-records-that-are-blank/#findComment-904243 Share on other sites More sharing options...
twilitegxa Posted August 23, 2009 Author Share Posted August 23, 2009 That didn't work. I have the notes field set as a longtext, if that helps. It is just blank if nothing has been entered. Does anyone know another way? Link to comment https://forums.phpfreaks.com/topic/171474-solved-not-display-records-that-are-blank/#findComment-904244 Share on other sites More sharing options...
Fog Juice Posted August 23, 2009 Share Posted August 23, 2009 That didn't work. I have the notes field set as a longtext, if that helps. It is just blank if nothing has been entered. Does anyone know another way? So it is not null, it's just an empty field? Couldn't you just do != ''? Or is the potential of being a few blank spaces? If that is the case maybe $get_sub_notes = "select notes from scout_sub_attributes where identity = '$identity' AND TRIM(notes) != '' "; Link to comment https://forums.phpfreaks.com/topic/171474-solved-not-display-records-that-are-blank/#findComment-904245 Share on other sites More sharing options...
twilitegxa Posted August 23, 2009 Author Share Posted August 23, 2009 Nevermind, I have set the field to be null and now it works. Thank you! Link to comment https://forums.phpfreaks.com/topic/171474-solved-not-display-records-that-are-blank/#findComment-904247 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.