Praticamente vorrei ordinare i messaggi in modo che compaiono all'inizio e non alla fine. Chi me lo sa aggiustare? Ho provato in tutti i modi D:

Codice PHP:
<?php
session_start
();
include(
'settings.php');
if(!isset(
$_SESSION['username'])) {
header('Location: login.php');
} else {
session_regenerate_id();
}
?>
<head><body bgcolor="#6397D0">
<title>(c) Ysoolder - Messaggi</title>
</head>
<body>
<?php
$my_id
= userId($_SESSION['username']);
?><?php include 'menu2.html';?></div>
</div></div>
</div></div>
<div id="content">
<?php
$my_username
= realUsername($_SESSION['username']);
?>
<div style="position:absolute; right: 10px;">

</div><p><br><head><meta http-equiv="refresh" content="3600; url=messaggi.php"> </head>
<p><center><div style="border: 1px solid black;width: 350px; height: 370px; overflow-y: scroll;">

<?php

$sel_request
= mysql_query("SELECT * FROM chat WHERE username LIKE '$my_username'");
if(
mysql_num_rows($sel_request) == 0) {
echo
"Nessun messaggio privato ricevuto.";
} else {
while(
$ref = mysql_fetch_row($sel_request)) {
$richiedente = $ref[1];
$messaggio = $ref[2];
?>
<form action="<?php echo $_SERVER['PHP_SELF']; ?>" method="POST">
<span style="font-weight: bold; margin-right: 30px;">

Da: <?php echo $richiedente; ?> </span>
<p>
<?php echo $messaggio; ?></form>

<?php
}
}
?>
<p>
<?php


?>
</div>
</div>
</div>

<?php
include 'scrivi.php';
?>

</body>
</html>