I am trying to generate dynamic images, I am using jquery to pass the id
of the image from the mysql db to produce dynamic result , but it doesn't seems to working it only printing one image , my code is here
<?php
include 'conn.php';
if (mysqli_connect_errno()) {
printf("Connect failed: %s
", mysqli_connect_error());
exit();
}
$query = "SELECT id FROM homebg";
$result = mysqli_query($conn, $query);
if ($result->num_rows > 0) {
while($row = $result->fetch_assoc()) {
foreach ($row as $value) {
echo "
<img class=\"responsive-img col l3\" id=\"img\">
<script>
$('#img').attr(\"src\",\"getImageadmin.php?id=\"+".$value.");
$('#img').show();
</script> ";
}
}
}
mysqli_close($conn);
?>
Here I want to pass the value(id
) of the image to the jquery used one by one , in each iteration so that it can print images one by one next to each other