+1  A: 

Use ORDER BY when you do the SELECT. Check this: http://dev.mysql.com/doc/refman/5.0/en/sorting-rows.html

ionut bizau
A: 

Ok here is all i can do but still doesn't work any ideas Come on gurus i need help

//index.php

From

//ajax.js

function sort(orderByType)
 {
  $.ajax({
    url: "sort.php",
    type:"get",
    data: "orderby="+orderByType,
    success:function(data){
   alert(data);
    $("t1").text(data);}
  });

 }

//sort.php

$con = mysql_connect("localhost","root","root");
if (!$con) {
 die('Could not connect: ' . mysql_error());
}

$orderBy = $_GET['orderby'];

mysql_select_db("icrisis", $con);

$result = mysql_query("SELECT * FROM messages,user  
         where user_id = from_user
         ORDER BY user_name".$orderBy);


 while($row = mysql_fetch_array($result))
   {  
  echo "<tbody><tr><td>"."&#8226;"."</td><td>".$row["Time_Date"]."</td><td>".$row["player_name"]."</td><td></td><td></td><tr><td></td><td colspan='4'>".$row["msg_desc"]."</td></tr></tbody>";
     }


mysql_close($con);

?>

It doesn't see the $orderBy And then i want to add the new order to my page how could that be done

Sarah