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
Post a Comment