Salve con questo codice:
codice:
<?php
$hostname = ""; //it is "localhost" (without quotes) in most cases
$db_username = "";
$db_password = "";
$db_name = "";
/*
* connect to the database
*/
$link = mysql_connect($hostname, $db_username, $db_password);
mysql_select_db($db_name);
header("Vary: Accept");
header("Content-Type: text/html;charset=UTF-8");
echo'<?xml version="1.0" encoding="UTF-8?>';
$q = "SELECT * FROM contacts ORDER BY created_at DESC";
$r = mysql_query($q);
if(mysql_num_rows($r)>0):
?>
<?php
while($row = mysql_fetch_assoc($r)):
?>
<br> <br>
<table border="0" bgcolor="<?php if ($row["Sesso"]=="Uomo"){echo "#5877ac";} else{echo "#ff99ff";} ?>" width="300" height="40">
<tr>
<td style='text-align:left;'><?php echo $row["Sesso"];?> <?php echo " - "; ?> <?php echo $row["Anni"];?> <?php echo " Anni "; ?>
</tr>
</table>
<table border="0" bgcolor="#E4E4E4" width="300" height="150" gt;
<tr>
<?php echo "<td>" . wordwrap($row['Messaggio'], 86, "<br />\n") . "</td>"; ?>
</tr>
<td><a href='javascript:;' class='action view-details' id='<?php echo $row["contact_id"]; ?>'>(Visualizza Tutto)</a></td>
<table border="0" bgcolor="#E4E4E4" width="300" height="40" gt;
<tr>
<td> <?php echo $row["created_at"]; ?> </td>
</tr>
</table>
<?php
endwhile;//end while for looping non-empty result set.
elseif(mysql_num_rows()==0)://nothing in the database
?>
<div class='welcome-bg'>
Benvenuto<br/>
<a href='javascript:showPage("add");' class='add_button' style='margin:auto;'></a>
</div>
<?php endif; //endif for non-empty result set ?>
Ottengo questo:

Io invece voglio ottenere questo: (voglio mostrare i contenuti estratti dalla query in orizontale da 3 o 4 colonne, poi va a capo e si ripete il tutto con gli altri contenuti)

Cosa devo modificare?
Grazie in anticipo