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 Link to comment https://forums.phpfreaks.com/topic/102101-displaying-data-from-query-in-joined-tables/ 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... Link to comment https://forums.phpfreaks.com/topic/102101-displaying-data-from-query-in-joined-tables/#findComment-522666 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 Link to comment https://forums.phpfreaks.com/topic/102101-displaying-data-from-query-in-joined-tables/#findComment-522669 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.. } Link to comment https://forums.phpfreaks.com/topic/102101-displaying-data-from-query-in-joined-tables/#findComment-522673 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.. } Link to comment https://forums.phpfreaks.com/topic/102101-displaying-data-from-query-in-joined-tables/#findComment-522675 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 Link to comment https://forums.phpfreaks.com/topic/102101-displaying-data-from-query-in-joined-tables/#findComment-522679 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.