#1
  1. No Profile Picture
    Junior Member
    Devshed Newbie (0 - 499 posts)

    Join Date
    Jul 2000
    Posts
    26
    Rep Power
    0
    Hi all,

    I seem to be having a problem finding the correct code to use for referencing two tables with uid's. The code below manages to find out what the user id is. But I cannot see how one is to reference this id variable to my "horoscope" table, that contains this id. I have been through the Mysql manual, but cannot find any info on my subject. The code fails as indicated below:

    Any tips would great

    Regards

    Richard

    <html>
    <head>
    <title>Untitled Document</title>
    <meta </head>


    <?
    /* This php3.0 script will verify login and password verification. Plus provide customer profile. For the customer to edit.
    */

    $con=mysql_connect('localhost','username','password');

    //make connection to the database

    mysql_select_db('data base name,$con);

    // Check to see if login name and password is correct

    $result = mysql_query("select* from user where login='$login' and passw='$passw'");
    if(!mysql_numrows($result)) {

    // Login is not accepted

    echo "HELLO, $login $passwordn";
    echo "You have entered an incorrect passwordn";
    exit;
    }else{
    //Login sucessful

    //find out the name of person logging in.

    echo "Thanks for logging in $login, $uidn";


    // Find all of the services that the user has subscribed too.


    $result = mysql_query("select uid as id from user where login='$login' and passw='$passw'");

    $row=mysql_fetch_array($result);

    echo "User ID:".$row["id"]; ////////// JUST TESTING here!!
    ?>


    <?

    ///////// The problem seems to be here somewhere ????/////////
    $result = mysql_query("select horo from horoscope where uid='$id');
    $row=mysql_fetch_array($result);

    ?>

    <select name="horo">
    <option value="<? print $row["horo"]?>" selected><None>
    </option>
  2. #2
  3. .Net Developer
    Devshed Novice (500 - 999 posts)

    Join Date
    Feb 2000
    Location
    London
    Posts
    987
    Rep Power
    15

    $result = mysql_query("select horo from horoscope where uid='$id');

    From where you are getting this $id variable..
    --------------------------------
    if it is coming from previos query then try..


    // Find all of the services that the user has subscribed too.

    $result = mysql_query("select uid as id from user where login='$login' and passw='$passw'");

    $row=mysql_fetch_array($result);

    //echo "User ID:".$row["id"]; ////////// JUST TESTING here!!


    $id=$row["id"];
    //assign id value to $id variable before issueing next query..

    ?>


    <?

    ///////// The problem seems to be here somewhere ????/////////
    $result = mysql_query("select horo from horoscope where uid='$id');
    $row=mysql_fetch_array($result);

    ?>

    <select name="horo">
    <option value="<? print $row["horo"]?>" selected><None>
    </option>


    whole thing can be done in a single query...just try how we can do that..Just tell me if that is very difficult for you...


    ------------------
    SR -
    webshiju.com

    "The fear of the LORD is the beginning of knowledge..."

    [This message has been edited by Shiju Rajan (edited July 23, 2000).]
  4. #3
  5. Banned (not really)
    Devshed Supreme Being (6500+ posts)

    Join Date
    Dec 1999
    Location
    Brussels, Belgium
    Posts
    14,642
    Rep Power
    4476
    You can do this with one select statement

    $query = "select horo from horoscopes h, user u where h.uid = u.uid and u.login='$login' and u.passw='$passw'"

    Hope that helps..

    ---John Holmes...

Similar Threads

  1. Referencing a field from another table.
    By kingtoad in forum PHP Development
    Replies: 7
    Last Post: February 16th, 2004, 06:13 PM
  2. Referencing a field from another table.
    By kingtoad in forum MySQL Help
    Replies: 0
    Last Post: February 16th, 2004, 02:43 PM
  3. League table problem
    By silverduck in forum MySQL Help
    Replies: 8
    Last Post: February 10th, 2004, 12:38 PM
  4. how to keep table on top, not centered??
    By vinyl in forum HTML Programming
    Replies: 2
    Last Post: January 20th, 2004, 06:19 PM
  5. Controlling Multiple table Heights in a Browser
    By AttaBoy in forum HTML Programming
    Replies: 1
    Last Post: December 10th, 2003, 04:24 AM

IMN logo majestic logo threadwatch logo seochat tools logo