----- Original Message ----- From: "drparker" <[EMAIL PROTECTED]> To: <[EMAIL PROTECTED]> Sent: Thursday, March 06, 2003 2:42 PM Subject: [PHP] retrieve last n records
> I need to retrieve the last n records of a table, n will probably be 2 > or 3. I know that I can accomplish this by: select * from table order > by field DESC Limit n, but i would prefer not to do this way because it > interferes with my sorting mechanism on the main page. Is there any > other way to do it? Retrieve your records as normal and using mysql_data_seek() to move the results pointer to the desired row then start your loop. http://www.php.net/manual/en/function.mysql-data-seek.php Please note this is not an efficient way to accomplish the goal. LIMIT is certainly the way to go and you should be able to do any sorting you need within the SQL statement. After all retrieving, ordering and grouping database information is what SQL was designed to do. - Kevin -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php