Jump to content

how to display data from two different table with the same column names


Recommended Posts

I have these two tables. One of it is (tbllocation) and the other (tbldistrict).

 

So i need to display the datas but the problem is both of the column names that i wanna display have same column names which is (description).i dont know how to do it.if i use both (description), it will only show the data from (tbllocation).

 

so here are my codes

 

 


<table style="text-align: left; width: 715px; height: 32px;"
border="1" cellpadding="2" cellspacing="2">
  <tbody>
    <tr>
      <td colspan="2" rowspan="1"
style="font-style: italic;">List-Location</td>
    </tr>
    <tr>
      <td style="font-style: italic;">code</td>
      <td style="font-style: italic;">description</td>
      <td style="font-style: italic;">districtid</td>      
    </tr>

<?
$query="SELECT * FROM tbllocation
LEFT JOIN tbldistrict ON tbllocation.districtid = tbldistrict.id";

        $result=mysql_query($query);
while($row=mysql_fetch_array($result)) { 
$code = $row['code'];
$description = $row['description'];
    $districtid = $row['districtid'];    
echo "<tr><td>$code</td>";
echo "<td>$description</td></tr>";
echo "<td>$districtid</td></tr>";


}
?>
  </tbody>
</table>

 

 

 

 

and the photo explains from what it is now(photo 1)..and how do i want it to be..(photo 2)

post-131669-13482403587721_thumb.jpg

post-131669-13482403587879_thumb.jpg

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.