Jump to content


Photo

Displaying data from linked tables


  • Please log in to reply
1 reply to this topic

#1 adwfun

adwfun
  • New Members
  • Pip
  • Newbie
  • 4 posts

Posted 13 September 2006 - 05:06 AM

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>";
}
?>

#2 fenway

fenway
  • Staff Alumni
  • MySQL Si-Fu / PHP Resident Alien
  • 16,199 posts
  • LocationToronto, ON

Posted 13 September 2006 - 03:12 PM

You're not actually issuing that query.
Seriously... if people don't start reading this before posting, I'm going to consider not answering at all.




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users