$sql='SELECT * FROM `categorias`';
$tabla = mysql_query($sql);
$troncales_son=0;
while ($reg = mysql_fetch_array($tabla)) {
$id = $reg['id'];
$nombre = $reg['nombre'];
if (troncal($id)) {
$troncales_name[$troncales_son] = $nombre;
++$troncales_son; // cantidad de categorias troncales
}
}
sort($troncales_name); // ordena los elementos alfabeticamente
$N=3;
$filas=ceil($troncales_son/$N);
$porcentaje = round (100/$N)."%"; // porcentaje de cada fila
$i=0;
for ($f=0;$f<$filas;$f++){
for ($c=0;$c<$N;$c++){
$elem[$f][$c] = $troncales_name[$i];
// echo $i." ".$troncales_name[$i];
++$i;
}
}
$folder_icon_s = '<http://upload.wikimedia.org/wikipedia/commons/thumb/f/f3/Folder.svg/48px-Folder.svg.png">';
//$enlace = '<a href="http://www.betadir.com/directorio-web.htm#Ciencia">'.$elem[$f][0].'</a>';
// Creo tabla
$tabla='<table width="669" border="1">';
for ($f=0;$f<$filas;++$f){
$fila = "
<tr>
<td width='".$porcentaje."'>".$folder_icon_s.url_maker ($elem[$f][0])."</td>
<td width='".$porcentaje."'>".$folder_icon_s.url_maker ($elem[$f][1])."</td>
<td width='".$porcentaje."'>".$folder_icon_s.url_maker ($elem[$f][2])."</td>
</tr>";
//echo $fila;
$tabla = $tabla . $fila;
}
$tabla= $tabla.'</table>';
echo $tabla;
Listo!
