Jump to content

Recommended Posts

[quote author=wildteen88 link=topic=107255.msg430034#msg430034 date=1157653074]
Use this as the query:
SELECT * FROM users_table ORDER BY user_id_column DESC LIMIT 1
Should select the last row from the database
[/quote]

assuming your table is set up with an auto-incrementing primary key ;-) lol

you really will have to give us a little more information than that. if you have an id column that is an auto-increment field, that's probably your best bet. however, if you have a date column that records the membership date, something like that could be used as well. if you don't have any sort of ordering available to you, i'm afraid you might be stuck!
Link to comment
https://forums.phpfreaks.com/topic/20034-help-needed/#findComment-87976
Share on other sites

If you do not have an auto-incrementing primary key or date column (which would be bad practice), getting info will be much more process heavy. Since MySQL by default orders data by date inserted (ASC), I guess you could (theoretically, mind you) select ALL the usernames into an array, and then use array_pop() to get the last username.

Just an idea.
Link to comment
https://forums.phpfreaks.com/topic/20034-help-needed/#findComment-87989
Share on other sites

[quote author=wildteen88 link=topic=107255.msg430154#msg430154 date=1157662704]
Well ideally any table should have an auto incrementing column, which will be the primary key. Howev i was pressed for time when I was posting, so I just rushed the post abit.
[/quote]
i figured as much ;) so i thought i'd clarify for you...

one other thought... i'm not sure how mysql handles this, but in postgresql, you have a pid that is generated as a bookmark for the server, and you never even see it (even through phpmyadmin) unless you specifically query for it. i suppose if mysql has something similar, you could order by that as well.
Link to comment
https://forums.phpfreaks.com/topic/20034-help-needed/#findComment-88318
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.