Welcome Guest, Not a member yet? Register   Sign In
Get last 10 record
#1

[eluser]zend[/eluser]
Hello am new in CI. Am looking for example how i can get last 10 article from DB table.

I have table products and now i want show last 10 products added. Only last 10 products.

Any example how cani do that
#2

[eluser]Otemu[/eluser]
Hi,

You can do something like this
SELECT field1, field2, field3
FROM myTable
//have a field in your database with ON UPDATE CURRENT_TIMESTAMP then use order by clause
ORDER BY lastupdate ASC
//or if your fields have an incremented number or you know that the last field updated will be always higher then you could use
ORDER BY numbercolumn ASC
//Then you can limit the return results
LIMIT 10
#3

[eluser]Harold Villacorte[/eluser]
Or if you have an auto increment id field you can order by that DESC.
#4

[eluser]zend[/eluser]
Ty for replay i go to try.




Theme © iAndrew 2016 - Forum software by © MyBB