andrew_biggart Posted May 28, 2008 Share Posted May 28, 2008 Can anyone explain how to select two tables and display data from each table on the same page ???? Thanks in advance here is the page im trying to do it on !! i can get the first one sorted just cannot get the second table working it is for the user info at the bottom of the page. <?php include("config.php"); $item_id=$_GET['id']; // Retrieve data from database $sql="SELECT * FROM $tbl_name WHERE item_id='$item_id'"; $result=mysql_query($sql); // Start looping rows in mysql database. while($rows=mysql_fetch_array($result)){ ?> <table class= "select_header"width="400" border="0" cellspacing="0" cellpadding="4"> <tr> <td style="width: 392px">Buying item : <? echo $rows['item_id']; ?> </td> </tr> </table> <br/> <table class= "select_myebaygrey"width="400" border="0" cellspacing="0" cellpadding="4"> <tr> <td class="style31">CAUTION, CAUTION, CAUTION !!!!!!! </td> </tr> </table> <br/> <table> <tr><td> <img alt="caution" src="caution.jpg" /></td> <td style="width: 86%"><strong><span class="style32">Caution you are about to purchase this item !</span></strong><br /> <br /> <span class="style19">If you do not want to please go back immediately as when ever this form is processed you will have to pay for this item.<br /> <br /> Please insure all details are filled in and then submit the form.<br /> <br /> <strong>Thanks for shopping with Urbanwear.</strong></span></td></tr> </table> <br/> <table class= "select_myebaygrey"width="400" border="0" cellspacing="0" cellpadding="4"> <tr> <td>Item Title : </td><td style="width: 370px"><? echo $rows['item_name']; ?></td> </tr> </table> <br/> <table class= "select_main"width="400" border="0" cellspacing="0" cellpadding="4"> <tr><td style="width: 227px"rowspan="7"><? echo "<img src='images/". $rows['item_image'] . "' style='width:200px; height:200px;' />";?></td></tr> <tr><td style="width: 125px" class="style29"><span class="style28">Starting price :</span> £</td><td><? echo $rows['item_starting_price']; ?></td></tr> <tr><td class="style29" style="width: 125px"><span class="style28">Current price :</span> £</td><td></td></tr> <tr><td style="width: 125px" class="style29"><span class="style28">Time left : </span> </td><td><? echo $rows['end_date']; ?></td></tr> <tr><td class="style29" style="width: 125px"><span class="style28">Seller ID : </span> </td><td><? echo $rows['user_id']; ?></td></tr> <tr><td class="style30" style="width: 125px">Number of bids : </td><td></td></tr> <tr><td class="style30" style="width: 125px">Highest Bidder : </td><td></td></tr> </table> <br/> <table class= "select_myebaygrey"width="400" border="0" cellspacing="0" cellpadding="4"> <tr> <td style="width: 370px">Item Description : </tr> </table> <br/> <table class= "select_des"width="400" border="0" cellspacing="0" cellpadding="4"> <tr><td class="des" style="width: 525px"><? echo $rows['item_description']; ?></td></tr> </table> <br/> <br/> <table class= "select_myebaygrey"width="400" border="0" cellspacing="0" cellpadding="4"> <tr> <td> </td> </tr> </table> <table class= "select_main"width="400" border="0" cellspacing="0" cellpadding="4"> <tr> <td style="width: 100%" class="style33">Please insure all of these details are correct! If some of them are incorrect please go back to your account first and modify the incorrect details and then return.</td> </tr> </table> <br/> <br/> <table class= "select_myebaygrey"width="400" border="0" cellspacing="0" cellpadding="4"> <tr> <td>This Product will be posted to this address !</td> </tr> </table> <table class= "select_main"width="400" border="0" cellspacing="0" cellpadding="4"> <tr> <td class="controls1" style="width: 108px">First Name</td><td class="details" style="width: 100px"><? echo $rows2['name']; ?></td> </tr> <tr> <td class="controls1" style="width: 108px">Last Name</td><td class="details" style="width: 100px"><? echo $rows2['lastname']; ?></td> </tr> <tr> <td class="controls1" style="width: 108px">Address</td><td class="details" style="width: 100px"><? echo $rows2['addresse_line_1']; ?></td> </tr> <tr> <td class="controls1" style="width: 108px">City</td><td class="details" style="width: 100px"><? echo $rows2['addresse_line_2']; ?></td> </tr> <tr> <td class="controls2" style="width: 108px; text-align: left;">Postcode</td><td class="details1"><? echo $rows2['postcode']; ?></td> </tr> </table> <br/> <br/> <table class= "select_myebaygrey"width="400" border="0" cellspacing="0" cellpadding="4"> <tr> <td>This Product will be charged to this Bank account Information !</td> </tr> </table> <table class= "select_main"width="400" border="0" cellspacing="0" cellpadding="4"> <tr> <td class="controls1" style="width: 112px">Account Holders First Name</td><td class="details" style="width: 100px"><? echo $rows2['account_fn']; ?></td> </tr> <tr> <td class="controls1" style="width: 112px">Account Holders Last Name</td><td class="details" style="width: 100px"><? echo $rows2['account_ln']; ?></td> </tr> <tr> <td class="controls1" style="width: 112px">Account Bank</td><td class="details" style="width: 100px"><? echo $rows2['account_bank']; ?></td> </tr> <tr> <td class="controls1" style="width: 112px">Account Type</td><td class="details" style="width: 100px"><? echo $rows2['account_type']; ?></td> </tr> <tr> <td class="controls1" style="width: 112px">Account Number</td><td class="details" style="width: 100px"><? echo $rows2['account_account']; ?></td> </tr> <tr> <td class="controls1" style="width: 112px">Account Sort Code</td><td class="details" style="width: 100px"><? echo $rows2['account_sort']; ?></td> </tr> <tr> <td class="controls1" style="width: 112px">Account Valid From</td><td class="details" style="width: 100px"><? echo $rows2['account_valid']; ?></td> </tr> <tr> <td class="controls2" style="width: 112px; text-align: left;">Account Expires On</td><td class="details1" style="width: 100px"><? echo $rows2['account_expires']; ?></td> </tr> </table> <br/> <br/> <br/> <table> <tr><td><strong><span class="style34">If you are sure all of this information is correct please </span></strong> </td><td><input name="Submit1" type="submit" value="Pay for this item !" /></td></tr> </table> <? // close while loop } // close connection mysql_close(); ?> Quote Link to comment Share on other sites More sharing options...
revraz Posted May 28, 2008 Share Posted May 28, 2008 You would use the MySQL JOIN function. Can anyone explain how to select two tables and display data from each table on the same page ???? Quote Link to comment Share on other sites More sharing options...
prcollin Posted May 28, 2008 Share Posted May 28, 2008 select CONCAT(column, " ", column2) from employee_data, employee_per where column3 = 'XXX' AND column4 = XXXX; 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.