|
|
Don't Show The Contents Of An Empty Field
I have a database which when queried brings back results one of which is an image name. The image name points to a subdirectory to display the image. Everything works fine but if there is no image name then the image is not found (obviously). How can I tell a result to not show the entry if it's empty?
The code goes something like this
mysql_select_db($databaseName,$db);
$result = mysql_query("SELECT * FROM reports WHERE target_page LIKE 'News' ORDER BY description",$db);
if ($myrow = mysql_fetch_array($result)) {
echo "
<table border=0 width=70%>n"; do { echo "
<tr>
n"; printf("
<td><B>%s</B></td>
</tr>n", $myrow["description"]); echo "
<tr>
n"; printf("
<td>%s</td>
</tr>n", $myrow["paragraph_1"]); echo "
<tr>
n"; printf("
<td>%s</td>
</tr>n", $myrow["paragraph_2"]); echo "
<tr>
n"; printf("
<td><IMG SRC=%s></td>
</tr>n", $myrow["image"]); echo "
n"; printf("
</tr>n", $myrow[""]); } while ($myrow = mysql_fetch_array($result)); echo "
</table>n"; } else { echo "Sorry, no records were found!"; } ?>
Any help would be appreciated
View Complete Forum Thread with Replies
See Related Forum Messages: Follow the Links Below to View Complete Thread
|
|
|