I have a script that calls up a picture stored in a database. I then have a script that displays said picture on another page. If there is no picture in the database I would like for their to be a no picture icon displayed.
New to php but I believe that some conditional statement is in order but I don't know where exactly to put it.
Here is the code to call up the picture. picscript1.php
<?php
$username = '';
$password = '';
$host = '';
$database = '';
mysql_connect($host, $username, $password) or die("Can not connect to database: ".mysql_error());
mysql_select_db($database) or die("Can not select the database: ".mysql_error());
$ID=$_GET['ID'];
$query = mysql_query("SELECT * FROM norestaurants WHERE ID='".$ID."'");
$row = mysql_fetch_array($query);
$content = $row['pic1'];
header('Content-type: image/jpg');
echo $content;
?>
The code to then display the picture:
<?
$ID=$_GET['ID'];
echo "<img src='picscript1.php?ID=".$ID."' alt='$Name' width='224' height='168'>";
?>
Now I can do a conditional in picscript1.php but that would not stop the image icon from appearing. How can I do it in the second bit of code that displays the picture?
Any help will be greatly appreciated.
Thanks