function counter()
{
static $count = 1;
return $count++;
}
echo("<table border=0><tr>");
for($i = 1; $i <=31; $i++)
{
$day = counter();
echo("<td bgcolor=#c0c0c0><a href=prenota.php?day=$day>$day</a></td>");
}
echo("</tr></table>");
esegui il ciclo ripetendo piu' td in file.
come avevi fatto tu, per ogni valore creava una riga nuova e tutte tabelle separate.