Ma chi si rivede
prova così:
codice:
$connessione = mysql_connect("localhost", "root", "")
or die(mysql_error());
mysql_select_db("prova",$connessione);
$sql = "SELECT * FROM anagrafica ORDER BY id DESC";
$query = mysql_query($sql) or die(mysql_error());
$num_record = mysql_num_rows($query);
$colonne = 2;
$tot_righe = $num_record/$colonne;
$i_x = 0;
$x_x = 0;
$k_x = 0;
$cell_width = floor(100/$colonne);
echo'<table width="100%" border="0" cellspacing="1" cellpadding="3" ><tr>';
while($array = mysql_fetch_array($query)){
$i_x++;
$k_x++;
$x_x++;
$nome=trim($array['nome']);
echo"<td width='$cell_width%'>$nome</td>";
if($i_x == $colonne) {
echo'</tr>';
if ($i_x == $colonne && (($x_x/$colonne) != $tot_righe)) {
echo'<tr>';
}
$i_x = 0;
} // fine $i_x == $colonne
} //fine del ciclo
if ($colonne <= $x_x){
if (($k_x%$colonne) != 0){
$indice = $k_x;
while (($indice%$colonne) != 0 ){
echo'<td>[img]images/trasp.gif[/img]</td>';
$indice++;
} //fine ciclo while
if(($indice%$colonne) == 0 ){
echo'</tr>';
}
} //fine ($k%$colonne)!= 0
} else{ //fine if $colonne <= $x
echo '</tr>';
}
echo '</table>';
modificato al volo da quello che uso io di solito, in teoria dovrebbe andare