i am trying to learn php & mysql. I have a table called image in the gallery database. I have stored 4 images in that table. I have this php script which should fetch images from the database. But on trying this on xampp server i am getting only one image from the database which is repeating 4 times. The code is :
<?php
session_START();
//$id = $_GET['id'];
$id = 1;
while ($id <= 4) {
$link = mysql_connect("localhost", "root", "#")
or die("Couldn't connect");
mysql_select_db("gallery") or die("Couldn't connect");
$sql = "SELECT img FROM image";
$result = mysql_query("$sql");
if ($result != 0) {
$row = mysql_fetch_assoc($result);
header("Content-type: image/jpeg");
echo $row['img'];
mysql_close($link);
} else {
echo("No data");
}
$id = $id + 1;
};
?>
I would be highly thankful to you if my problem gets resolved.