I've started developing a site that pulls two images randomly from a database.
I assign a random number to a variable, between 1 and the amount of images there are stored in my database. I then query the database looking for that ID, and show the image in HTML image tags. This works fine and the two images appear randomly and I have checking to make sure they are never the same. But sometimes, one or both of the images won't appear on the page but if I view the source code, they are appearing there.
( I should note that the images aren't actually stored WITHIN the database, just the names of them are )
Here is the code that I am using to withdraw them from the database
function selectImage($id)
{
$query = "SELECT * FROM Images WHERE id = $id";
$result = mysql_query($query) or die (mysql_error());
while($row = mysql_fetch_array($result) {
$image = $row['image'];
echo "<img src='" . $image . "' />";
}
}
Anyone know why this only displays the image sometimes? I'm refreshing to make it display another set of images.