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] Quote Link to comment 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"? Quote Link to comment 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? Quote Link to comment 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) != '' "; Quote Link to comment 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! 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.