SitePoint Sponsor

User Tag List

Results 1 to 6 of 6
  1. #1
    Non-Member
    Join Date
    Mar 2005
    Posts
    832
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Memberslist Code

    Can someone please give me a free memberslist code thats in alphabetical order.

    Thank you.

  2. #2
    SitePoint Enthusiast
    Join Date
    Oct 2004
    Location
    Sweden
    Posts
    49
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I assume you use MySQL and have a members table.

    PHP Code:
     $sql = ("SELECT member_name FROM members ORDER BY member_name ASC") or die (mysql_error());

    $result mysql_query($sql);

    while(
    $r=mysql_fetch_array($result)) {
     echo 
    $r['member_name'];
     echo 
    '<br />';

    That will list members in alphabetic order from you members table, (you have to change the column names of course).
    Saywoot.net - Online Comic!

  3. #3
    SitePoint Evangelist Tapan's Avatar
    Join Date
    May 2005
    Location
    India
    Posts
    563
    Mentioned
    1 Post(s)
    Tagged
    0 Thread(s)

    Smile

    Hi,

    Don't know what you mean by that but i think this is what you want

    PHP Code:
    $q1 "SELECT * FROM members ORDER BY name";
    $r1 mysql_query($q1) or die(mysql_error());
    $rows mysql_num_rows($r1);

    if (
    $rows == 0)
    {
            echo 
    "<center>There are no members in databse</center>";
    }
    else
    {
            while(
    $a1 mysql_fetch_array($r1))
            {
                    echo 
    $a1["name"] . "<br>\n";
            }

    Hope this helps.

    Thanks

  4. #4
    SitePoint Wizard silver trophy someonewhois's Avatar
    Join Date
    Jan 2002
    Location
    Canada
    Posts
    6,364
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by jispa
    I assume you use MySQL and have a members table.

    PHP Code:
     $sql = ("SELECT member_name FROM members ORDER BY member_name ASC") or die (mysql_error());
     
     
    $result mysql_query($sql);
     
     while(
    $r=mysql_fetch_array($result)) {
      echo 
    $r['member_name'];
      echo 
    '<br />';
     } 
    That will list members in alphabetic order from you members table, (you have to change the column names of course).
    Just a side note -- you want the "or die" on the query, not the definition. The assignment won't fail, the query could.

  5. #5
    SitePoint Enthusiast
    Join Date
    Oct 2004
    Location
    Sweden
    Posts
    49
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    PHP Code:
    $result mysql_query($sql) or die (mysql_error()); 
    like so?

    I didn't know that, thanks
    Saywoot.net - Online Comic!

  6. #6
    SitePoint Wizard Young Twig's Avatar
    Join Date
    Dec 2003
    Location
    Albany, New York
    Posts
    1,355
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Yup. That's perfect.


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •