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

 

 

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

 

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..
}

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.