Jump to content

[SOLVED] calling data from 2 tables


DeadDude

Recommended Posts

Here try this:

 


$query1="SELECT * FROM table1 WHERE unique_id='$uidsearch'";
$resultam=mysql_query($query1);

$query2="SELECT * FROM table2 WHERE unique_id='$uidsearch'";
$resulten=mysql_query($query2);

$query3="SELECT * FROM table3 WHERE unique_id='$uidsearch'";
$resulthd=mysql_query($query3);

 

I have been told it is good method I use it and it works great.

Link to comment
Share on other sites

After the code to open the database.

 

Mind you I am new to this as well I have only been programming in PHP for about a week now so there may be a better way to do it but here is a little piece of code I have put together for you.  This assumes that each table shares a common bond by having a unique ID for each record that matches the other tables.  So here goes:

 

# connection information
$username="SomeUSERnameHere";
$password="SomeUSERpassHere";
$database="YourDBname";
$dbhost="localhost";

# Connects to database
mysql_connect($dbhost,$username,$password);
@mysql_select_db($database) or die( "Unable to select database");

# Opens and searchs the database for a specific unique_id
$query1="SELECT * FROM table1 WHERE unique_id='$uidsearch'";
$resultam=mysql_query($query1);

$query2="SELECT * FROM table2 WHERE unique_id='$uidsearch'";
$resulten=mysql_query($query2);

$query3="SELECT * FROM table3 WHERE unique_id='$uidsearch'";
$resulthd=mysql_query($query3);

 

 

 

Link to comment
Share on other sites

yeah done that in the previous query to get the data from the first table.

 

i've been using cookies as well which my tutor is making me lol and at the moment the table won't display anything so just trying to make sure i have all the code there so he can help me work out how to get it to display in the end table

 

cheers for your help

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.