The aim is for a customer to upload their advert to the database, that triggers and email for approval. Once approved ad will display in location between the set dates.
I have written the code correctly to display by date and approval from an admin area. I just cannot get the image to display.
The code below details the process so far.
<?php
include('mysql_connect.php');{
$location='1';
}
$resultSet = $mysqli->query("SELECT * FROM adverts WHERE adloc = '$location' AND approval ='Y' ");
if($resultSet->num_rows > 0){
while($rows = $resultSet->fetch_assoc())
{
$id = $rows ['id'];
$start = $rows ['start'];
$end = $rows ['enddate'];
$business = $rows ['business'];
$email = $rows ['email'];
$tel = $rows ['tel'];
$web = $rows ['web'];
$advert = $rows ['image'];
$Date = date('Y-m-d');
$Date=date('Y-m-d', strtotime($Date));;
$DateBegin = date('Y-m-d', strtotime("$start"));
$DateEnd = date('Y-m-d', strtotime("$end"));
}
if (($Date > $DateBegin) && ($Date < $DateEnd))
{
echo "ADVERT";
echo '<img src="getad.php?id=$id">';
}
else
{
echo "FILLER IMAGE";
}
}
?>
The code for the getad.php file is as follows
if(isset($_GET['id']))
{
$id = mysqli_real_escape_string($_GET['id']);
$query = mysqli_query("SELECT * FROM adverts WHERE id= '$id'");
while ($row = mysqli_fetch_assoc($query))
{
$image = $row['image'];
}
header("content-type: image/jpeg");
echo $image;
}
else
{
echo "Error!";
}
?>
I am sure I can't be far off. The image is a JPEG LONGBLOB in the database.
Thank you.