jbond Posted April 21, 2008 Share Posted April 21, 2008 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 Quote Link to comment Share on other sites More sharing options...
zenag Posted April 21, 2008 Share Posted April 21, 2008 do u want to display fields from both tables??..pls explain in it ..clearly... Quote Link to comment Share on other sites More sharing options...
jbond Posted April 21, 2008 Author Share Posted April 21, 2008 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 Quote Link to comment Share on other sites More sharing options...
zenag Posted April 21, 2008 Share Posted April 21, 2008 i think ....... while($row=mysql_fetch_array($result)) { echo ... .... would help u.. } Quote Link to comment Share on other sites More sharing options...
zenag Posted April 21, 2008 Share Posted April 21, 2008 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.. } Quote Link to comment Share on other sites More sharing options...
jbond Posted April 21, 2008 Author Share Posted April 21, 2008 hmm.. probably your last suggestion is covering what I am looking after. Will give it a try.. Thanks Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.