Discover Habbo's history
Treat yourself with a Secret Santa gift.... of a random Wiki page for you to start exploring Habbo's history!
Happy holidays!
Celebrate with us at Habbox on the hotel, on our Forum and right here!
Join Habbox!
One of us! One of us! Click here to see the roles you could take as part of the Habbox community!


Results 1 to 9 of 9

Thread: SQL Help [+rep]

  1. #1
    Join Date
    Dec 2006
    Posts
    3,970
    Tokens
    0

    Latest Awards:

    Default SQL Help [+rep]

    SELECT * FROM user_sys WHERE USERNAME='Tom743'

    If i use that on this table;

    user_sys
    ID USERNAME PASSWORD NAME
    1 Tom743 12345password Tom
    2 Bob222 54321password Bob
    3 BillGates fail Bill
    4 Harry password12345 Harry


    i can get this;

    ID USERNAME PASSWORD NAME
    1 Tom743 12345password Tom

    But from that is there any way to echo the NAME?

    Hopefully you understand what i mean lol.
    Lets set the stage on fire, and hollywood will be jealous.

  2. #2
    Join Date
    Sep 2005
    Location
    East London
    Posts
    3,028
    Tokens
    0

    Latest Awards:

    Default

    PHP Code:
    <?
    // DB CONNECTION

    $g mysql_query("SELECT * FROM `user_sys` WHERE `USERNAME`='Tom743'");
    $h mysql_fetch_assoc($g);
    print 
    $h[username];
    ?>
    SUMMIN I SED WAS WRONG, TA SIMON

    PHP Code:
    print $h[username]; 
    to


    PHP Code:
    print $h[password]; 
    EDIT: Simon, im just too fast!
    Last edited by Jackboy; 08-06-2008 at 07:26 PM.

  3. #3
    Join Date
    May 2005
    Location
    San Francisco, CA
    Posts
    7,160
    Tokens
    2,331

    Latest Awards:

    Default

    PHP Code:

    $query 
    mysql_query"SELECT * FROM `user_sys` WHERE `USERNAME` = 'Tom743'" );

    $fetch mysql_fetch_array$query );

    echo 
    $fetch["NAME"]; 

  4. #4
    Join Date
    Dec 2006
    Posts
    3,970
    Tokens
    0

    Latest Awards:

    Default

    Quote Originally Posted by Invent View Post
    PHP Code:

    $query 
    mysql_query"SELECT * FROM `user_sys` WHERE `USERNAME` = 'Tom743'" );

    $fetch mysql_fetch_array$query );

    echo 
    $fetch["NAME"]; 
    Quote Originally Posted by Jackboy View Post
    PHP Code:
    <?
    // DB CONNECTION

    $g mysql_query("SELECT * FROM `user_sys` WHERE `USERNAME`='Tom743'");
    $h mysql_fetch_assoc($g);
    print 
    $h[username];
    ?>
    You basically use mysql_fetch_assoc when selecting all of ONE rows fields, but when selecting more, for instance a member list, you use mysql_fetch_array and do a while statement.

    If you wanted to display the password you would change

    PHP Code:
    print $h[username]; 
    to


    PHP Code:
    print $h[password]; 
    EDIT: Simon, im just too fast!
    Wow thanks I didnt know it would be that simple. +Rep to both of you.
    Lets set the stage on fire, and hollywood will be jealous.

  5. #5
    Join Date
    Apr 2007
    Posts
    2,431
    Tokens
    0

    Latest Awards:

    Default

    Quote Originally Posted by Tom743 View Post
    Wow thanks I didnt know it would be that simple. +Rep to both of you.
    You're kidding?

    [X] [X] [X]

  6. #6
    Join Date
    Dec 2006
    Posts
    3,970
    Tokens
    0

    Latest Awards:

    Default

    Quote Originally Posted by Pazza View Post
    You're kidding?
    About what?
    Lets set the stage on fire, and hollywood will be jealous.

  7. #7
    Join Date
    Dec 2007
    Posts
    1,683
    Tokens
    0

    Latest Awards:

    Default

    aha, even I knew this before.

    (mysql_fetch_array)

  8. #8
    Join Date
    Apr 2007
    Posts
    2,431
    Tokens
    0

    Latest Awards:

    Default

    Quote Originally Posted by Tom743 View Post
    About what?
    It being easy

    I cba learning w/e it is, it's too hard

    [X] [X] [X]

  9. #9
    Join Date
    May 2005
    Location
    San Francisco, CA
    Posts
    7,160
    Tokens
    2,331

    Latest Awards:

    Default

    Quote Originally Posted by Pazza View Post
    It being easy

    I cba learning w/e it is, it's too hard
    PHP is simple once you learn the basics.

Posting Permissions

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