title: Inserting php if statement within php code?
body: <p>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:</p>
  
  <pre><code>&lt;?php   
     if(strlen($query) &gt;= $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) &gt; 0){
     while($results = mysql_fetch_array($raw_results)){
  
     echo "&lt;table width='150' border='3'&gt;
     &lt;tbody&gt;&lt;tr&gt;
     &lt;td&gt;".$results['NAME']."&lt;br&gt;
     &lt;img  align='left' src='images/images/".$results['IMAGE']."'&gt; 
     &lt;/td&gt;
     &lt;/tr&gt;&lt;/tbody&gt;
     &lt;/table&gt;";            
     }          
     }    else{ echo "No results were found";
  
     }           
     }    else{ echo " ".$min_length; }
  ?&gt;
  </code></pre>
  
  <p>For the php if statement, I was thinking something along these lines:</p>
  
  <pre><code>&lt;?php if ($results['IMAGE'] != '') {  ?&gt;
  &lt;img src='images/icons/".$results['IMAGE']."' height="100" width="auto"&gt;
  &lt;?php }?&gt;
  </code></pre>