contiw Posted August 25, 2010 Share Posted August 25, 2010 How to extract the last row a query and store it in a variable ? Thanks for helping. Noob apppreciate. Quote Link to comment https://forums.phpfreaks.com/topic/211709-extract-last-row-of-a-query/ Share on other sites More sharing options...
AbraCadaver Posted August 25, 2010 Share Posted August 25, 2010 Reverse the ORDER BY and then extract the first row with *_fetch_array() or similar function. Quote Link to comment https://forums.phpfreaks.com/topic/211709-extract-last-row-of-a-query/#findComment-1103613 Share on other sites More sharing options...
Adam Posted August 25, 2010 Share Posted August 25, 2010 AbraCadaver's method is what you should go with, but if not possible for whatever reason here's an alternative that will advance the result pointer to the last row returned: $total = mysql_num_rows($query); mysql_data_seek($query, $total-1); Once you've "seeked" to the last row, mysql_fetch_*() will return the data. Quote Link to comment https://forums.phpfreaks.com/topic/211709-extract-last-row-of-a-query/#findComment-1103615 Share on other sites More sharing options...
contiw Posted August 25, 2010 Author Share Posted August 25, 2010 Thanx MrAdams, AbraCad. Quote Link to comment https://forums.phpfreaks.com/topic/211709-extract-last-row-of-a-query/#findComment-1103618 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.