Hi.
I'm trying to write a script that fetchs image codes from a mysql database to display them into a 3 columns html table.
I got this so far:
$selection = $_GET['scelta']; // Leggi il contenuto della variabile che determina la gallery
$query = 'SELECT code FROM `'. $selection.'`;'; // Codice SQL per la query
$result = mysql_query($query);
// E' necessario contare le righe risultanti della query per poi controllare che la tabella grafica abbia sempre 3 colonne
$rows_nb = mysql_num_rows($result);
print($rows_nb);
// Genero l'array associativo dalla query e inizializzo a 0 la variabile che conterĂ le immagini
$pic_num = 0;
$pic_code = mysql_fetch_array($result);
print('<table width="60%" border="0" align="center">'); // Stampo l'intestazione HTML della tabella
while ($row = mysql_fetch_assoc($result))
{
print('<tr>'); // Costruzione della riga
for ($tb_rows=0;$tb_rows<3;$tb_rows++)
{
if ($pic_num < $rows_nb) // Controllo per essere sicuri di non aver sforato con il numero di immagini
{
// Creo la cella, seleziono l'immagine giusta e inserisco il il tag e il link
print('<td><div align="center"><a href="show.php?code='. $pic_code[$pic_num] .'&gallery='. $selection .'"><img src="imagedb/thumbs/'.$pic_code[$pic_num] .'-small.jpg" border="1" /></a></div></td>');
/* DEBUGGING START */
print('<p>PIC_CODE: '. $pic_code[$pic_num] .'</p>');
/* DEBUGGING STOP */
$pic_num++; // Aumento il contatore delle foto inserite
}
else
{
print('<td></td>');
}
}
}
I'm sorry for the comments in italian but I didn't have time to delete them.
Anyway, the problem is that the $pic_code[$pic_num] trick doesn't work: only the first picture gets displayed and all the other are broken.
This is what happens in the generated page (first & second pics):
<td><div align="center"><a href="show.php?code=a_011"><img src="imagedb/thumbs/a_011-small.jpg" border="1" /></a></div></td>
<td><div align="center"><a href="show.php?code="><img src="imagedb/thumbs/-small.jpg" border="1" /></a></div></td>
You can see that the link and location of the first image are ok but all the other aren't.
I tried printing out the $pic_code[$pic_num] value under each picture but apart from the first all are empty.
What should I do?