Jump to content

Only echo if entry exists


dachshund

Recommended Posts

Im trying to work out how to only include the 'image' part of this code

<?php

$sql="SELECT * FROM entries ORDER BY id DESC LIMIT 10";
$result=mysql_query($sql);
?>

<?php
while($rows=mysql_fetch_array($result)){
$date = date('d/m', strtotime($rows['date']));
?>
<table width="100%" border="0" align="center" cellpadding="5" class="bottomborder">
<tr>
	<td align="left" bgcolor="#FFFFFF" class="contentmaintitle" valign="top">
	<? echo $rows['title']; ?>
        </td>
	<td align="right" bgcolor="#FFFFFF" class="wordsby" valign="top">
	<? echo $date; ?>
        </td>
</tr>
<tr>
	<td align="left" bgcolor="#FFFFFF" colspan="3" valign="top">
        <img src="<? echo $rows['image']; ?>" />
        </td>
</tr>
<tr>
	<td align="left" colspan="3" valign="top">
	<? echo $rows['object']; ?>
        </td>
</tr>
<tr>
	<td align="left" bgcolor="#FFFFFF" colspan="3" class="maincontent">
	<? echo $rows['post']; ?>
        </td>
</tr>
</table>
<?php
}
mysql_close();
?>

 

if there's actually an entry in there. Otherwise I want it not to include it at all.

 

Anyone know how to do that?

 

 

Link to comment
https://forums.phpfreaks.com/topic/106554-only-echo-if-entry-exists/
Share on other sites

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.