Trouble in substitution image with php-jquery
<p>I made some code rows to change recursively image after each click but doesn't work.
Thath code just show last image of directory when I click on the first thumb ...
Any idea why?
that's the code commented:</p>

<pre><code>&lt;?php
//DB connection
include ("conn.inc");
// parameter for DB query   
$rif_pippo = "id_pippo"; 
// DB query
$query = mysql_query("SELECT * FROM pippo WHERE rif_pippo ='$rif_pippo'"); 
$result = mysql_num_rows($query);
$row = mysql_fetch_assoc($query);
// div in wich there's IMG SRC to recursively change
echo "&lt;div&gt;&lt;img id='change_this'src='images/medium/".$row['rif_pippo']."/".$row['rif_pippo]."_medium01.jpg' alt='' /&gt;&lt;/div&gt;";
// thumbnails list
echo "&lt;ul&gt;";
// count how many images there are in directory
$images = glob('images/pippo/medium/'.$row[rif_pippo].'/*.jpg');
$images_number= count($images);
// cicle to show all directory's thumbnails
for ($i=1; $i&lt;=$images_number; $i++) {
// I change the images prefix adding a 0 for images betweeen 0 and 9
if ($i&lt;=9) {$v='0'.$i;}
else if ($i&gt;=10) {$v=$i;};
// JQUERY script 
echo "&lt;script type='text/javascript'&gt;";
echo "$('#id_box_foto').click(function() {";
echo "$('#change_this').attr('src','images/medium/".$row['rif_pippo']."/".$row['rif_pippo']."_medium".$v.".jpg').stop(true,true).hide().fadeIn('slow');";
echo "return false";
echo "});";
echo "&lt;/script&gt;";

// thumbnail to change IMG SRC
echo "&lt;li&gt;&lt;a href='#id_box_foto' id='id_box_foto'&gt;&lt;img class='foto' style='border:0px;' src='images/thumbnails/".$row['rif_pippo']."/".$row['rif_pippo']."_thumb".$v.".jpg' alt='' /&gt;&lt;/a&gt;&lt;/li&gt;";
}

echo "&lt;/ul&gt;";

?&gt;
</code></pre>
