avrei bisogno di uno script ke i risultati del mio select sn + di 3 (e multipli di 3) mi crea un'altra riga della mia tabella e mi và a capo....
Come posso fare????![]()
![]()
Grazie in anticipo....
avrei bisogno di uno script ke i risultati del mio select sn + di 3 (e multipli di 3) mi crea un'altra riga della mia tabella e mi và a capo....
Come posso fare????![]()
![]()
Grazie in anticipo....
Prima utilizzavo questo...
Codice PHP:
$query = "select * from.......";
$result = mysql_query ($query) or die .....;
$numero_righe=mysql_num_rows($result);
echo "<table border=.......";
while($a_row=mysql_fetch_array($result))
{
{
$i+=1;
if (($i%3)!=1)
{
echo "<td width=......>";
echo ".....</td>";
}
else
{
echo "</tr><tr><td width=......";
echo ".....</td>";
}
}
}
ma ora ottengo l'errore
Codice PHP:
Notice: Undefined variable: i in.........
Come posso risolvere???
prova qualcosa del genere
Dove $my_array è l'array contenente i dati che vuoi mostrare, $divide è il numero di dati per riga.codice:<?php $my_array = array("Ciao", "Mamma", "Guarda", "Come", "Mi", "Diverto", "...", "Questo", "Esemprio", "Fa", "Proprio", "Pena,", "Scusate!"); $divide = 3; ?> <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"> <html> <head> <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1"> <title>Untitled Document</title> </head> <body> <table border="1" cellpadding="10" cellspacing="10"> <?php for ($j = 0; $j <= floor(count($my_array)/$divide); $j++) { ?> <tr> <?php for ($i = $j*$divide; $i < ($j+1)*$divide && $i < count($my_array); $i++) { ?> <td bordercolor="#999999" ><?php echo($my_array[$i]);?></td> <?php } ?> </tr> <?php } ?> </table> </body> </html>
![]()
<´¯)(¯`¤._)(¯`»ANDREA«´¯)(_.¤´¯)(¯`>
"The answer to your question is: welcome to tomorrow"
ho modificato il tutto ksì;
---------------------------------------------------------
$query = "select * from.......";
$result = mysql_query ($query) or die .....;
$numero_righe=mysql_num_rows($result);
echo "<center><table border=2 style=\"border-collapse: collapse\" width=480><center>";
while($a_row=mysql_fetch_array($result))
{
$my_array = array($a_row['photo']);
$divide = 3;
for ($j = 0; $j <= floor(count($my_array)/$divide); $j++)
{
print "<tr>";
for ($i = $j*$divide; $i < ($j+1)*$divide && $i < count($my_array); $i++)
{
print "<td bordercolor=\"#999999\">";
print ($my_array[$i]);
print "</td>";
}
print "</tr>";
}
}
---------------------------------------------------------
ma nn funge.....
o per meglio dire.....mi crea tante righe per quanti sono i risultati....
secondo me l'errore è in
Codice PHP:
$my_array = array($a_row['photo']);
può essere????
Non funziona perché il fetch che fai
mysql_fetch_array carica una riga di result alla volta, non l'intera colonna 'photo', per quello lo script non funziona.codice:while($a_row=mysql_fetch_array($result))
<´¯)(¯`¤._)(¯`»ANDREA«´¯)(_.¤´¯)(¯`>
"The answer to your question is: welcome to tomorrow"
prova così:
codice:<table border="1" cellpadding="10" cellspacing="10"> <tr><?php $counter = 0; while($a_row=mysql_fetch_array($result)) { if ($counter == $divide) { $counter = 0; ?></tr> <tr><?php } ?><td><?php echo($a_row['photo']); $counter++; ?></td><?php } ?> </tr> </table>
<´¯)(¯`¤._)(¯`»ANDREA«´¯)(_.¤´¯)(¯`>
"The answer to your question is: welcome to tomorrow"
Grazie Andrea1979 funziona correttamente, sei 1 grande
![]()
![]()