Salve!
ho 3 pagine: index.php
Codice PHP:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>Guestbook</title>
<style type="text/css">
table{
text-align:center;
border:1px solid #ff0000;
width:60%;
}
tr, td{
text-align:center;
border:1px dotted #ff0000;
width:60%;
</style>
</head>
<body>
<table>
<tr>
<td>
<h1>Lascia un tuo saluto!</h1>
</td>
</tr>
<tr>
<td>
<form action="guest.php" method="post">
Inserisci il tuo nome:
<input type="text" id="utente" name="utente" /></p>
Inserisci il messaggio:
<textarea name="messaggio" rows="5" cols="30"></textarea>
<input type="submit" value="Procedi!">
<input type="reset" value="Cancella">
</form>
</td>
</tr
<?php
include ("database.txt");
?>
</table>
</body>
</html>
... una pagina guest.php:
Codice PHP:
<?php
$utente=$_POST['utente'];
$messaggio=$_POST['messaggio'];
$data_ora = date("d/m/Y H:i:s");
$db_testo="database.txt";
if($utente==""){
echo "Il nome inserito non è corretto, inserisci il nome";
}elseif($messaggio==""){
echo "Inserisci il tuo messaggio";
}else{
$guestbook = fopen($db_testo, "a");
$txt='<tr><td>[b]'.$utente.'[/b]
';
$txt .= $messaggio . "
";
$txt .= "[i]Messaggio scritto in data: " . $data_ora . "[/i]</td></tr>";
fwrite($guestbook, $txt);
fclose($guestbook);
echo '[url="index.php"]Torna indietro[/url]';
}
?>
ed un database "database.txt" che compongono il mi guestbook...
La domanda è: come faccio ad ordinare i commenti facendo sì che i più recenti appaiano in alto e i più vecchi in basso?
Grazie in anticipo!