php help please guys
Posted: Sun Jan 18, 2015 5:02 pm
hello guys,
im displaying my images from my MySQL database how would i get it so if they don't have an image it dosent display the image as with the code i use below it displays a box even though there isn't an image in the database.
im displaying my images from my MySQL database how would i get it so if they don't have an image it dosent display the image as with the code i use below it displays a box even though there isn't an image in the database.
Code: Select all
<?php require("./styles/top.php");?>
<p>Latest News</p>
<?php
include("includes/connect.php");
$select_posts = "select * from posts";
$run_posts = mysql_query($select_posts);
while($row=mysql_fetch_array($run_posts)){
$post_id = $row['post_id'];
$post_title = $row['post_title'];
$post_date = $row['post_date'];
$post_author = $row['post_author'];
$post_image = $row['post_image'];
$post_keywords = $row['post_keywords'];
$post_content = substr($row['post_content'],0,200);
}
?>
<?php echo $post_title; ?><br />
Published on:<?php echo $post_date ?> By <?php echo $post_author ?><br /><br />
<center><img src="/cms/pics/<?php echo $post_image; ?>" width="500" height="300" /></center>
<?php echo $post_content; ?><br />
<p align="left"><a href="pages.php?id=<?php echo $post_id; ?>">Read More</a></p>
<?php require("./styles/bottom.php");?>