salve popolo di html avrei bisognio un aiuto mi potrste dire perche questo script mi legge solo le prime cinque news? e non mi legge tipo ci sono 5 news nel db aggiungo una elimina la piu vecchia e mi fa vedere questa aggiunta? mi potete aiutare ragazzi grazie ciao
Codice PHP:
<?php
$host = 'localhost'; # l'host in cui risiede il database (IP)
$user = 'root'; # la username per accedere al database
$pass = ''; # la password per accedere al database
$db = '3333'; # il nome del database
mysql_connect($host,$user,$pass); #connessione al database
mysql_select_db($db); #selezionee al database
$tot = 5; # il numero di news da visualizzare
$i = 0; # variabile che servirà da indice (che incrementeremo)
$query = "SELECT id,titolo,testo,DATE_FORMAT(data, '%d.%m.%Y') as newData
FROM news
ORDER by data desc
LIMIT 0,$tot";
$result = mysql_query($query);
$output = 'tot='.mysql_num_rows($result);
while($news = mysql_fetch_array($result))
{
$output .= '&data'.$i.'='.$news['newData'];
$output .='&titolo'.$i.'='.urlencode($news['titolo']);
$output .='&testo'.$i.'='.urlencode(substr($news['testo'],0,2000));
$i++;
}
echo $output;
?>