I have a script that people register for and i was wondering how can I get the five newest members from the database.
Thanks in advance for the help.
Without knowing more it is impossible to say. But basically you use a query that looks something like this:
SELECT columns FROM table WHERE something ORDER BY a_value_that_is_incremented LIMIT 0, 5
I see, well what more would I need to post to get the best help?
theprofession wrote:I see, well what more would I need to post to get the best help?
Basically, the structure of your database table from which you want to retrieve the data.
username varchar(30) No password varchar(32) Yes NULL userid varchar(32) Yes NULL userlevel tinyint(1) No email varchar(50) Yes NULL timestamp int(11) No bio text No
is this what your talking about?
userid sounds like it holds numerical data. Why isn't it a numerical column? Furthermore, should each username have a unique userid? This is a field that sounds like it be a primary key and be an AUTO_INCREMENT field.
What is the timestamp field? Is that the timestamp that they were registered? Since it's an integer, I'm guessing this is a Unix timestamp? If you answered yes to both questions, an example query would be:
SELECT `username`, (other fields) FROM `mytable` ORDER BY `timestamp` DESC LIMIT 5
ok and that can be set in the code with php right? sorry if its a bad questions just trying to understand it better.
theprofession wrote:ok and that can be set in the code with php right?
ok and that can be set in the code with php right?
What are you referring to by "that" ? If you're talking about point #1 of my above post, then no, I was proposing a change in the structure of your SQL table.
Oh ok...that just threw me way off.