Jump to content

[SOLVED] Not display records that are blank?


twilitegxa

Recommended Posts

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]

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"?

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) != '' ";

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.