displaying image in php mysql
Posted: Fri Jun 12, 2015 10:01 pm
hello,
can anyone help me please i want to check to make sure that the image exists if it dosent dont display an image if it does exist then display the image this is the line of code.
can anyone help me please i want to check to make sure that the image exists if it dosent dont display an image if it does exist then display the image this is the line of code.
Code: Select all
Full Page Code:-<img src="../news_pics/<?php echo $post_image; ?>" width="100" height="100">
Code: Select all
<?php include('styles/top.php'); ?>
<div id="left">
<?php
include("includes/connect.php");
$select_posts = "SELECT * FROM news ORDER BY post_id DESC LIMIT 1";
$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_content = substr($row['post_content'],0,200);
?>
<h2>
<a href="pages.php?id=<?php echo $post_id; ?>">
<?php echo $post_title; ?>
</a>
</h2>
<p align="left">Published on: <b><?php echo $post_date; ?></b></p>
<p align="right">Posted by: <b><?php echo $post_author; ?></b></p>
<center><img src="news_pics/<?php echo $post_image; ?>" width="500" height="300" /></center>
<p align="justify"><?php echo $post_content; ?></p>
<p align="right"><a href="pages.php?id=<?php echo $post_id; ?>">Read More</a></p>
<hr>
<?php } ?>
</div>
<?php include('styles/bottom.php'); ?>