how to fetch last recodset from database in php

hi
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
e.g

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

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

and

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

SELECT * FROM tablename ORDER BY reg DESC LIMIT 1;

I hope this will helpful for you.
SR

Thats it
Thanks Sarthak Patel Bro

it's nice that your problem solve. keep posting more issues and receive fast and correct solution. ~~sr~~
Sponsor our Newsletter | Privacy Policy | Terms of Service