listo
Código PHP:
<?php
echo "<table align=center>";
include ('conexion.php');
$query = ("SELECT * FROM galeria ORDER BY id DESC limit 0,18");
$result = mysql_query( $query );
if( !is_resource( $result ) ) {
die("Problema con el Query:".mysql_error());
}
$columnes = 3;
if (($rows=mysql_num_rows($result))==0) {
echo "<tr><td colspan=$columnes>No hay resultados en la BD.</td></tr>" ;
}
for ($i=1; $row = mysql_fetch_row ($result); $i++) {
$resto = ($i % $columnes);
if ($resto == 1) {echo "<tr>";}
echo '<td width="170"><span class="menuarriba"><div align="center"><a href="index.php?modulo=gente_araucana_preview&id='.$row[0].'"><img src='.$row[3].' alt="Ampliar" border="0"></a><br><strong>'.$row[1].'</strong><br>('.$row[2].')</div></td>';
if ($resto == 0) {echo "</tr>";}
}
if ($resto <> 0) {
$ajust = $columnes - $resto;
for ($j = 0; $j < $ajust; $j++) {echo "<td> </td>";}
echo "</tr>";
}
echo "</table>";
?> </div>