In order to do this, you will need at least one other field in your MySQL table: a date/time stamp. Then, simply SELECT the desired results from the table, using ORDER BY and DESC on the date/time stamp field, like so:
SELECT * from instantmsgs ORDER BY <date/time stamp field> DESC
That should do it! Hope that helps!