如何通过某些东西回复变量[duplicate]

This question already has an answer here:

I created a table that contains message, sender, to, time I want to echo message ordered by time that is my code.

$query= mysql_query("SELECT * FROM  `table` GROUP BY `sender` ORDER BY `time` DESC")or die(mysql_error());
while($arr = mysql_fetch_array($query)){
$num = mysql_num_rows($query);
$msg = $arr ['message'];
echo '</br>';
echo $msg;
}

that shows me the first message from each sender I want to show the last message from each sender, So how can I do this

Thanks :)
Klaus

</div>

try this :

SELECT * FROM  (select * from table order by `time` desc) t1 GROUP BY `sender`