0

I'm working on a project that involved getting information from two different servers. What i plan on doing is having the user enter his or her username password and then have a php script fill in the rest of the fields below first name last name etc. I did some searching and found that some of the data i have is on two different tables within the server. Below is the coding I have so far.

 <?php
    $connect = mysql_connect("localhost","**************","**********") or die ("Couldn't Connect"); //host,username,password
    mysql_select_db("*******") or die ("Could not find database");

    $query = mysql_query("SELECT * FROM jos_users WHERE username='$username'");


    ?>
    <html>
    <form action="populate.php" method='post'>
     <table>
    <tr>
            <td>VAE&nbsp;Username:</td>

            <td><input type='text' name='username' value=''></td>
          </tr>
          <tr>
            <td>VAE&nbsp;Password:</td>

            <td><input type='password' name='password' value=''></td>
          </tr>
     </table>
      <p><input type='submit' name='submit' value='Search & Populate!'></p>
</form>
//below is the information i want filled in from the MYSQL tables
    <hr>
    $query = mysql_query("SELECT * FROM jos_users WHERE username='$username'");
    <form action="dafreg.php" method='post'>
    <table>
    <tr>
    <td>Fristname:</td>
    <td><input type='text' name='firstname' value='<?php echo $firstname; ?>'></td>
    </tr>
    <tr><td>Lastname:</td>
    <td><input type='text' name='lastname' value='<?php echo $lastname; ?>'></td>
    </tr>
    <tr>
    <td>Login:</td>
    <td><input type='text' name='login' value='<?php echo $username; ?>'></td>
    </tr>
    <tr><td>Password:</td>
    <td><input type='text' name='pass' value=''></td>
    </tr>
    <tr><td>Country:</td>
    <td><input type='text' name='country' value=''></td>
    </tr>
    <tr><td>Pilot:</td>
    <td><input type='checkbox' name='pilot' value=''></td>
    </tr>
    <tr><td>ATC:</td>
    <td><input type='checkbox' name='atc' value=''></td>
    </tr>
    <tr><td>Email:</td>
    <td><input type='text' name='email' value=''></td>
    </tr>
     </table>
     <p><input type='submit' name='submit' value='Register'></p>
     </form>





    </form>


    </html>
2
  • 2
    You don't make much sense. Are you on two different servers, databases or tables ? Commented Mar 9, 2012 at 10:48
  • It'd be helpful if you could please strip off the unnecessary html and post only the part relevant to your problem. Commented Mar 9, 2012 at 16:04

2 Answers 2

1

Using 'JOIN' will be the best option for extracting the data multiple table...

SELECT tab1.*,tab2.*
FROM table1 tab1 JOIN table2 tab2
ON tab1.id=tab2.id
WHERE tab1.username=$username
Sign up to request clarification or add additional context in comments.

Comments

1

If the two tables are on the same database you could left join the two tables based on a common factor (probably username in this case)

SELECT *
FROM jos_users
LEFT JOIN table_name2
ON jos_users.username=table_name2.username
WHERE jos_users.username = $username

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.