display image from a mysql table

images php coding issues or problems here.

Moderators: macek, egami, gesf

Post Reply
thandono
New php-forum User
New php-forum User
Posts: 44
Joined: Sun Jan 01, 2012 3:06 am

Re: display image from a mysql table

Post by thandono » Tue Jan 03, 2012 1:16 pm

Separate code into two php files?

main.php

Code: Select all

... //mysql connect
$sql="SELECT id FROM store";
$result=mysql_query($sql) or die("Invalid Query:" . mysql_error());
while($row=@mysql_result($result, $num ,'id')) {
  echo '<img src='image.php?ID=$row'/>';
  exit;
}
image.php

Code: Select all

Header("Content-type: image/jpeg");
$ID = $_GET['ID'];
... //mysql connect
$sql="SELECT image FROM store WHERE id=$ID";
$result=mysql_query($sql) or die("Invalid Query:" . mysql_error());
while($row=@mysql_result($result, $num ,'image')) {
  echo $row;
  exit;
}

Post Reply

Who is online

Users browsing this forum: Yahoo [Bot] and 1 guest