Jump to content

Displaying data from query in joined tables


jbond

Recommended Posts

Hi Everyone,

 

I issue a query joining two tables

 

$sql="SELECT * FROM tbl_claims, tbl_multicon WHERE tbl_claims.be_filenum=tbl_multicon.be_filenum AND tbl_claims.be_filenum='$beclaim'";

$result=mysql_query($sql) or die(mysql_error());

$row=mysql_fetch_assoc($result);

 

 

tbl_claims contains a field that lists only 1 container. tbl_claims and tbl_multicon are linked together by means of a common field name. When a user asks for a detail using the link via tbl_claims he automatically received detailed information about more containers that are part of this particular claim. Both tbl_claims and tbl_multicon contain a field called container.

I would like to display the container number from the first table (tbl_claims) but don't know on how to do this. Displaying $row['container'] grabs the info from the second table. How can I display the container info from the first table without issueing a new query ?

 

Thanks for your assistance

 

 

Link to comment
Share on other sites

Yes that is basically the idea. The main tbl_claims contains one containernumber, the tbl_multicon can contain more containernumbers (excluding the containernumber from tbl_claims). The containernumbers from tbl_multicon (if they exist) are displayed on the screen. However I don't know on how to display the containernumber from the first table without building a new query ..

 

 

below is the line that displays the containernumbers in tbl_multicon, but the main question now is on how to access that one container that sits in tbl_claims??

 

 

 

<div class="detail_container"><?php if($row['multicon'] == "Y") { $result=mysql_query($sql) or die(mysql_error());

$row=mysql_fetch_assoc($result); while ($row=mysql_fetch_assoc($result)) { echo $row['container'] . " "; } }?></div>

 

 

Trust this explains a bit better

 

Link to comment
Share on other sites

or this might help...?????
$sql="SELECT tbl_claims.containernumber as contnum,tbl_multicon.containernumber FROM tbl_claims, tbl_multicon WHERE tbl_claims.be_filenum=tbl_multicon.be_filenum AND tbl_claims.be_filenum='$beclaim'";
while($row=mysql_fetch_array($result))
{

echo $row["contnum"];
echo $row["containernumber"];
....
would help u..
}

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.