Jump to content


ORDER BY


2 replies to this topic

#1 pukirocks

    Young Padawan

  • Members
  • Pip
  • 75 posts
  • Gender:Male

Posted 14 May 2007 - 05:11 PM

hi!! i'm writing a newest member php, i have my users DB and this code to which have a userjoin row that has the joining order so the latests user could be display, i can display only 1 member but i want to display more, i'm a newb using ORDER BY, here's my code

if ($total_members > 1) {
		$newest_member = $sql->db_Select("user", "userid, username, userimage", "userban='0' ORDER BY userjoin DESC LIMIT 0,1");
		$row = $sql->db_Fetch();

thanks in adnvance

#2 rc69

    PHP Master PD

  • P2L Staff
  • PipPipPipPip
  • 3,827 posts
  • Gender:Male
  • Location:Here
  • Interests:Web Development

Posted 14 May 2007 - 06:44 PM

Umm, Adam, you didn't change anything... LIMIT 0,1 and LIMIT 1 mean the same thing. They syntax is LIMIT start_record,num_records. Since he want's to select more members, he need simply to remove the LIMIT.

Puki, sql is simple, you read through it like you would read a book. The problem isn't whith ORDER BY, but with the LIMIT.
if ($total_members > 1) {
		$newest_member = $sql->db_Select("user", "userid, username, userimage", "userban='0' ORDER BY userjoin DESC");
		while($row = $sql->db_Fetch()){
			// display here
		}
Of course, if you want to display a certain amount of users, not all of them, just put the LIMIT back in and change "1" to how ever many you want.

#3 pukirocks

    Young Padawan

  • Members
  • Pip
  • 75 posts
  • Gender:Male

Posted 15 May 2007 - 03:41 PM

worked like a charm, thanks!!





1 user(s) are reading this topic

0 members, 1 guests, 0 anonymous users