Jump to content

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


scarezekiel

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

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.