how to fetch last recodset from database in php


i want to know that how to fetch last record available in database or the last sequence number(e.g if autonumber is on and the records are not in any order then how to fetch the last squence)


Well, do you mean you have a table with a field that you want the highest or lowest value of?
That would depend on the field you are talking about. There are tons of ways to sort values of fields.
Tell us what the current SQL query is and which field in it your want the highest of…

This is basically a SQL question and should be simple. Just need to know a little about the table and field you want to get the last of…


i mean that

reg# first name last name email
1 abc xyz
6 xyz abc
3 aaa bbb

so my question is that in the above order the data is stored in dbase
so how to get the latest reg# like in above example is 6 as its not the first record nor last record
should i first have to sort and then get the last record or is there any way to get that latest record without sorting


also how to get the last record
as i m using mysql_fetch_array() function to get record

hello mohsin1122, to fetch last record available in database. use below query for fetch record replace tablename with your database table. replace reg with your field name


I hope this will helpful for you.


Thats it
Thanks Sarthak Patel Bro

it's nice that your problem solve. keep posting more issues and receive fast and correct solution. ~~sr~~