ciao prova così:

Codice PHP:
<?php
include("config.php");
$sql "select hotel, foto, link from albergo where stelle= '3' order by rand()";
$risultato = @mysql_query($sql,$connessione)
or die(
"Impossibile eseguire l'interrogazione.");
$i 0;
while (
$riga mysql_fetch_array($risultato)) {
    
$hotel $riga['hotel'];
    
$foto_name $riga['foto'];
    
$link $riga['link'];
    
$hotelucwords(strtolower($hotel));
    
$comuneucwords(strtolower($comune));
    if(
$i%3==0){
    print 
"<img src=public/$foto_name>
<span class=linkhotel>[url="
$link"]$hotel[/url]</span>
"
;
    echo 
"
"
;
    }
    print 
"<img src=public/$foto_name>
<span class=linkhotel>[url="
$link"]$hotel[/url]</span>
"
;
    
$i++;
}

?>