I want to show all images from database in interface the page index.php
<?php while($row = $result->fetch_assoc()) { ?>
<table border="1" width="702" height="149" align="center">
<tr>
<td width="148"><img src='get.php' width='200' height='211' /> </td>
</tr>
</table>
<?php } ?>
the code in get.php
<?php
include ("config.php");
$image = mysql_query ("SELECT image.image FROM image JOIN products
WHERE image.id = products.Image_ID");
$image = mysql_fetch_assoc ($image);
$image = $image ['image'];
header ("Content-type: image/jpeg");
echo $image;
?>
but it gives me one image repeated in index.php.. How can I make the code take the Image_ID from the index.php to show all images in the same page?
Advertisement
Answer
This is your index.php
<?php while($row = $result->fetch_assoc()) { ?>
<table border="1" width="702" height="149" align="center">
<tr>
<td width="148"><img src='get.php?id='<?= $row['id'];?> width='200' height='211' /> </td>
</tr>
</table>
<?php } ?
And get.php
<?php
include ("config.php");
$image = mysql_query ("SELECT image.image FROM image JOIN products
WHERE image.id = '".$_GET['id']."'");
$image = mysql_fetch_assoc ($image);
$image = $image ['image'];
header ("Content-type: image/jpeg");
echo $image;
?>