Micro Niche Builder
Closed Thread
Results 1 to 2 of 2

Thread: simple SELECT FROM query

  1. #1

    Default simple SELECT FROM query

    Could someone help with a simple MySQL request. I seem to be having trouble selecting from more than one field in the same table.

    TABLE: User Data
    |-----------------------|
    username | password
    |-----------------------|

    Code:

    $result = mysql_query ("SELECT `username` FROM `User Data`")
    or die(mysql_error());

    $row = mysql_fetch_row($result); // converts the result into an array

    mysql_close($link);

    echo $row[0] ;

    This snip of code works fine to return one value but I want to select the 'username' and 'password' columns FROM 'user data' WHERE 'username' = '$username' AND 'password' = '$password'

    ... in one query.

    the $username $password variables are delivered via query string.
    Thanks & regards,
    Lokananth
    Live Chat Software By miOOt


  2. Micro Niche Builder

  3. #2

    Default

    You can try out this:
    Code:
    $result = mysql_query ("SELECT `username`,`password` FROM `User Data`")
    or die(mysql_error()); 
    
    $arr = mysql_fetch_array($result); into an array
    
    mysql_close($link);
    
    echo $arr[`username`] ;
    echo $arr[`password`] ;

Closed Thread

Similar Threads

  1. How I can get more query from my blog
    By spandey in forum SEO Forum
    Replies: 9
    Last Post: 10-09-2009, 11:10 PM
  2. Query Optimization
    By gilbertsavier in forum Databases
    Replies: 0
    Last Post: 07-17-2009, 07:24 AM
  3. Help me to select domain name
    By urvisoni in forum Domain Forum
    Replies: 5
    Last Post: 05-23-2009, 12:23 PM

Tags for this Thread

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