Page 1 of 1
How Can Get The Last Registered User Name ?
Posted: Sat Jan 07, 2006 6:04 am
by saqib389
how can i get the last registered users name....
for example
Last Sign Up User
ABC
Wat should be the code ?
i m sorry for asking these kind of question.. actually i m new.

Posted: Sat Jan 07, 2006 6:15 am
by sheila
If each record has a timestamp field to note when it was created, then you need to run a query and find out which has the latest 'created' date. Can't offer any more help without seeing the structure of your table.
Posted: Sat Jan 07, 2006 6:15 am
by twigletmac
Do you store your registered users in a database? Do you store the date and time that they registered?
Mac
Posted: Sat Jan 07, 2006 6:28 am
by saqib389
yes i store in database
table users------
Code: Select all
CREATE TABLE users (
userid int(25) NOT NULL auto_increment,
first_name varchar(25) NOT NULL default '',
last_name varchar(25) NOT NULL default '',
email_address varchar(255) NOT NULL default '',
username varchar(25) NOT NULL default '',
password varchar(255) NOT NULL default '',
info text NOT NULL,
signup_date datetime NOT NULL default '0000-00-00 00:00:00',
activated enum('0','1') default NULL,
decrypted_password varchar(255) NOT NULL default '',
PRIMARY KEY (userid),
UNIQUE KEY username (username)
) TYPE=MyISAM COMMENT=' Membership Information';
here is the info of my table
what shuld b the code to get the last registered user name ?
Posted: Sat Jan 07, 2006 6:56 am
by mickd
well, one can assume that the highest userid would be the most recent signup...
a query something like this:
*UNTESTED*
Code: Select all
SELECT max(userid) as lastregistered FROM users
Posted: Sat Jan 07, 2006 7:31 am
by pilau
mickd wrote:well, one can assume that the highest userid would be the most recent signup...
Yeah this is exactly what I thought of doing. But if you have a timestamp record on your users table it's much better to my opinion. More fail-safe, and more accurate.
Posted: Sat Jan 07, 2006 7:32 am
by neophyte
Assuming you are using MYSQL and you you just performed an insert on the table you can find out the last inserted id with
mysql_insert_id.
Posted: Sat Jan 07, 2006 8:08 am
by Jenk
mysql_last_insert_id() only returns the id of the last inserted record for that connection

Posted: Sat Jan 07, 2006 11:56 am
by saqib389
what would b the query ?
or code for getting this ?
i m confused..!

Posted: Sat Jan 07, 2006 11:59 am
by timvw
If you don't keep a datetime or (autoincrement) identifier it's impossible to find out.. As soon as you have that, you can SELECT MAX(column) FROM table.. Nothing confusing about it.
Posted: Sat Jan 07, 2006 12:37 pm
by Chris Corbyn
Code: Select all
select username from users_table where time_registered = max(time_registered) limit 1
Posted: Sat Jan 07, 2006 8:52 pm
by spamyboy
useful
Posted: Sat Jan 07, 2006 11:10 pm
by josh
oorrr...
Code: Select all
SELECT `username` from `users` ORDER BY `userid` DESC LIMIT 1