last row
Moderator: General Moderators
- hob_goblin
- Forum Regular
- Posts: 978
- Joined: Sun Apr 28, 2002 9:53 pm
- Contact:
last row
how would i return the LAST row of table?
well, if there's an id, you can order by id desc and then it would become the first row....
or you use the (is using mysql) mysql_fetch_row
or you use the (is using mysql) mysql_fetch_row
Code: Select all
$number = mysql_num_rows($connection);
$row = mysql_fetch_row($connection);
$rowї$number]; //being the last row- hob_goblin
- Forum Regular
- Posts: 978
- Joined: Sun Apr 28, 2002 9:53 pm
- Contact:
that doesn't work completely right...
here is the thing:
they are natural numbers, and the closest idea i've gotten was to sort them in descending order, and grab the first row using "limit" or something like that, then using it's # and adding 1...
could someone try to put that idea into code? I don't know how to use 'limit', and couldn't find any tutorials on it
here is the thing:
they are natural numbers, and the closest idea i've gotten was to sort them in descending order, and grab the first row using "limit" or something like that, then using it's # and adding 1...
could someone try to put that idea into code? I don't know how to use 'limit', and couldn't find any tutorials on it
- twigletmac
- Her Royal Site Adminness
- Posts: 5371
- Joined: Tue Apr 23, 2002 2:21 am
- Location: Essex, UK
Try this:
Mac
Code: Select all
SELECT field1, field2, field3 FROM table ORDER BY id DESC LIMIT 1