it looks like you're already getting all the messages in an array, just reverse the array:
PHP: array_reverse - Manual
you could have something in the php code like this:
if(isset($rev)):
$myarray=array_reverse($myarray);
endif;
and if $rev isn't set, it would display as it does now, but once its set, the array will come up in reverse.