Jump to content

Displaying data from linked tables


adwfun

Recommended Posts

I have 2 tables named City and District in MySQL.
Table City fields : CityID, CityName
Table District fields : DistrictID, DistrictName, CityID

I linked District to City. When retrieving data from District Table, how could I display CityName instead of cityID ?

My codes as follow:
What's problem ?

<?php
include("connectdb.php");
$district=mysql_query("select * from District");
while ($result=mysql_fetch_array($district))
{
echo $result["DistrictID"]."<br>";
echo $result["Districtname"]."<br>";
echo $result["select Districtname, Cityname from District, City where City.CityID=District.CityID"]."<br>";
}
?>
Link to comment
https://forums.phpfreaks.com/topic/20593-displaying-data-from-linked-tables/
Share on other sites

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.