I have a php script that is basically querying my database and providing details about each store, and including an image. The code pulls in the image fine, but currently if no image exists in the database, I have spacer image being inserted instead. Instead of using a spacer image though, is there a way for me to use a PHP 'if' statement inside of the php code to not render an image if the database has no image listed? Here is the basic query code:
<?php
if(strlen($query) >= $min_length){$query = htmlspecialchars($query);
$query = mysql_real_escape_string($query);
$raw_results = mysql_query("SELECT * FROM stores WHERE `TRAVEL` = '1' AND `STATE` = '$query'") or die(mysql_error());
if(mysql_num_rows($raw_results) > 0){
while($results = mysql_fetch_array($raw_results)){
echo "<table width='150' border='3'>
<tbody><tr>
<td>".$results['NAME']."<br>
<img align='left' src='images/images/".$results['IMAGE']."'>
</td>
</tr></tbody>
</table>";
}
} else{ echo "No results were found";
}
} else{ echo " ".$min_length; }
?>
For the php if statement, I was thinking something along these lines:
<?php if ($results['IMAGE'] != '') { ?>
<img src='images/icons/".$results['IMAGE']."' height="100" width="auto">
<?php }?>