SitePoint Sponsor

User Tag List

Results 1 to 5 of 5
  1. #1
    SitePoint Enthusiast ErikN's Avatar
    Join Date
    Jul 2001
    Posts
    84
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    specific, and general

    i would like to pull user-specific information from a database, which i am doing already, with:
    PHP Code:
    $sql "SELECT username
         FROM 
    $table_name
         WHERE username = \"
    $username\" and password = password(\"$password\")
    "

    is there a way that i can pull information from the database, on the same page, that isn't user-specific? because i would also like to do:
    PHP Code:
    $sql "SELECT username
         FROM 
    $table_name
    "

    i want to list some other users on the same page, but i dont know if i have to do something different or what...thanks in advance!

  2. #2
    SitePoint Evangelist ucahg's Avatar
    Join Date
    Apr 2001
    Location
    Sarnia, Ontario, Canada
    Posts
    434
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I think that would work.

    Just try it in your MySQL program before coding it in with php.

  3. #3
    SitePoint Zealot New Oddity's Avatar
    Join Date
    Jun 2001
    Location
    Georgia
    Posts
    102
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Each query to the MySQL database is a seperate request... It is like asking, "Can I ask you more than one question in a conversation?" You can have as many queries on the same page as you want.

    PHP Code:

    $sql1 
    "SELECT username
         FROM 
    $table_name
         WHERE username = '
    $username' AND
         password = PASSWORD('
    $password')";

    $sql2 "SELECT username
         FROM 
    $table_name";

    $result1 mysql_query($sql1);
    $result2 mysql_query($sql2);

    //do stuff to info 
    or you can do it in series as oposed to in parralel...

    PHP Code:

    $sql 
    "SELECT username
         FROM 
    $table_name
         WHERE username = '
    $username' AND
         password = PASSWORD('
    $password')";

    $result mysql_query($sql);

    //do stuff to info

    $sql "SELECT username
         FROM 
    $table_name";

    $result mysql_query($sql);

    //do stuff to info 
    --Odd
    "We all live in a yellow subroutine."
    "Some call it insanity; I call it inspiration!"

  4. #4
    SitePoint Enthusiast ErikN's Avatar
    Join Date
    Jul 2001
    Posts
    84
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    but since i am pulling a variable with the same name from each query, how would i make it so that it knows the difference between the two?

  5. #5
    Making a better wheel silver trophy DR_LaRRY_PEpPeR's Avatar
    Join Date
    Jul 2001
    Location
    Missouri
    Posts
    3,428
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Originally posted by ErikN
    but since i am pulling a variable with the same name from each query, how would i make it so that it knows the difference between the two?
    they're 2 different queries so it doesn't need to know the diff between the 2. it's fine, do as many query as you want.


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
  •