What is the problem in this PHP code?

Hi everyone,

I am strugling to make my php code word. I want to randomly display an image with data stored in my database. Here is the code


$retour_messages2=mysql_query("SELECT * FROM `nuke_gallery` WHERE proprio='$nomusager'");
while ($resultat2=mysql_fetch_array($retour_messages2))

{
$nom_album=$resultat2['album'];
$retour_total=mysql_query("SELECT COUNT(*) AS total FROM nuke_gallery_image WHERE proprio='$nomusager' AND album='$nom_album'");
$donnees_total=mysql_fetch_assoc($retour_total);

$total=$donnees_total['total'];


$nbimages=$total;
$i=0;
$retour_messages2=mysql_query("SELECT * FROM `nuke_gallery_image` WHERE album='$nom_album'");
while ($resultat2=mysql_fetch_array($retour_messages2))

{

$nomimages['$i']=$resultat2['nom_image'];
echo$nomimages['$i'];


}
srand((double)microtime()*1000000);
$affimage=rand(1,$nbimages);
$numero_image="[" .$affimage. "]";
$nom_image="$nomimages";

$image_voulue=$nom_image . $numero_image;



?>

<img src="mig/albums/<?echo $nomusager;?>/<?echo $nom_album;?>/<?echo "$nomimage"; echo$numero_image;?>" border=0 width=50 height=50 alt="Image aléatoire">

What's wrong with that code?
I know that $nomimages['$i']=$resultat2['nom_image']; works fine as well as the random number selection part.
 
Back
Top