Hi,
I would like to use the PHP reset array function to put the pointer at the beginning of an existing array inseted of requery the database each time.
How am I supposed to use that reset call ?
This is the piece of code I have, and I always get an error if I call reset so I am currently requiring the DB :-(
The not working version:
$sql_foto = "SELECT posizione FROM immagini WHERE idarticolo = $idarticolo";
$esito_foto = mysql_query($sql_foto);
$limite = 15;
$numero = 1;
for ($i = 1; $i <= $limite; $i++) {
$n = 1;
printf("\t\t\t\t<TR>\n");
while ($n <= 2) {
while ($riga_foto=mysql_fetch_array($esito_foto)) {
if ($riga_foto[posizione] == $numero) $colore = "color=\"#FF0000\"";
}
printf("\t\t\t\t\t<TD align=\"center\"><font face=\"Arial, Helvetica, sans-serif\" size=\"1\" $colore>".$numero."</font></TD>\n");
$n = $n + 1;
$numero = $numero + 1;
$colore = "";
reset($esito_foto);
}
The working version with requery:
$sql_foto = "SELECT posizione FROM immagini WHERE idarticolo = $idarticolo";
$limite = 15;
$numero = 1;
for ($i = 1; $i <= $limite; $i++) {
$n = 1;
printf("\t\t\t\t<TR>\n");
while ($n <= 2) {
$esito_foto = mysql_query($sql_foto);
while ($riga_foto=mysql_fetch_array($esito_foto)) {
if ($riga_foto[posizione] == $numero) $colore = "color=\"#FF0000\"";
}
printf("\t\t\t\t\t<TD align=\"center\"><font face=\"Arial, Helvetica, sans-serif\" size=\"1\" $colore>".$numero."</font></TD>\n");
$n = $n + 1;
$numero = $numero + 1;
$colore = "";
}
Thank you for any help about
Fabio