I have a php code that gets a list of images and then shows them in this way:
<?php
$query_selfie = "SELECT * FROM selfie ORDER BY RAND() LIMIT 30";
$stmt_selfie = $dbh->query($query_selfie);
if($stmt_selfie->rowCount() > 0)
{
$i = 0;
while($dati_selfie = $stmt_selfie->fetch(PDO::FETCH_ASSOC))
{ $i++;?>
<a href="profilo?id=<?php echo $dati_selfie['user_id'];?>" id="slf-<?php echo $i;?>" class="thumbnail slf" style="margin-top:10px;margin-bottom:0px !important;margin-left:0px !important;margin-right: 0px !important;border: 0 !important;">
<img src="show_selfie.php?id=<?php echo $dati_selfie['id'];?>" alt="Immagine profilo" />
</a>
<?php } ?>
<?php } ?>
So, for example it generates 30 <img>
tags. What I want to do is display only one of this, then show another one..the problem is that the id passed to the page which shows the image (src attribute) is selected by random. There is a way to do that?
EDIT
I've added the slf class because there are a lot of thumbnails in the page, but only these are interested in this question.
I have to display only one of the image which have been selected by the query, then change the image after a delay. The problem is that I have to save somewhere the id of the image because the src attributes have a link and I have to pass the id of the image.