mysql - Displaying an image in php -


how display blank if there no image in record.as have inserted record in database without image while fetching record displaying blank image in front end.it should not show image if there no image.here code. if there no image should show description.

blogimage.php

<tbody> <?php include "blogs.php" ; while($row =  mysql_fetch_array($result)) {?>             <tr>     <td><img src="admin/upload/<?php echo $row['image'];?>" height="100" style="width:60%;height:50%;"/></td> </tr> <tr> <td><?php echo "<p style='width:60%;'>" .$row['blog_description']."</p>"; ?></td> </tr> <?php }?> </tbody> 

blogs.php

$id=$_get['title']; $res = "select *  blogs   blog_title='$id'";  $result=mysql_query($res); 

try changing this

<img src="admin/upload/<?php echo $row['image'];?>" height="100" style="width:60%;height:50%;"/> 

to this

<?php if($row['image']) echo "<img src='admin/upload/".$row['image']."' height='100' style='width:60%;height:50%;' />"; ?> 

Comments

Popular posts from this blog

sublimetext3 - what keyboard shortcut is to comment/uncomment for this script tag in sublime -

java - No use of nillable="0" in SOAP Webservice -

ubuntu - Laravel 5.2 quickstart guide gives Not Found Error -