Ho un elenco di categorie, con questo codice lo organizzo in 4 colonne.
Il codice l'ho preso già fatto e poi adattato.
Ma ho questo errore:
Warning: mysql_num_rows() expects parameter 1 to be resource, string given... on line 81:
81) $num_record = mysql_num_rows($queryCat);
GrazieCodice PHP:<?php
$nomeTabellaCat = $tbl_prefix."categorie_lavoro";
$queryCat = "SELECT * FROM $nomeTabellaCat ORDER BY nome ASC";
$sqlCat = @mysql_query($queryCat);
// $query = @mysql_query("SELECT * FROM tbl_image_gallery");
// $row_rs_imagegallery = mysql_fetch_assoc($query);
$num_record = mysql_num_rows($queryCat);
$colonne = 4;
$tot_righe = $num_record/$colonne;
$i_x = 0;
$x_x = 0;
$k_x = 0;
$cell_width = floor(100/$colonne);
echo '<table border="0" cellspacing="1" cellpadding="3"><tr>';
while ($datiCat = mysql_fetch_array($sqlCat))
{
$urlCat = $datiCat['url_cat'];
$nomeCat = htmlentities(stripslashes($datiCat['nome']));
$i_x++;
$x_x++;
$k_x++;
echo ('<td width=\"$cell_width%\" border=0 align=top />[url="'.$docRoot.'tpl_lavoro_cat.php?cat='.$urlCat.'"]'.$nomeCat.'[/url]');
if($i_x == $colonne) { echo'</tr>';
if ($i_x == $colonne && (($x_x/$colonne) != $tot_righe)) { echo'<tr>';
} $i_x = 0;
}
} if ($colonne <= $x_x){ if (($k_x%$colonne) != 0){
$indice = $k_x;
while (($indice%$colonne) != 0 ){
// echo'<td></td>';
$indice++;
}
if(($indice%$colonne) == 0 ){ echo'</tr>';
}
}
}
else{ echo '</tr>';
}
echo '</table>';
?>

Rispondi quotando
