Hello
Rather than taking the simple route and adding all the date to a single table I am trying to be good and follow some database normalisation rules. But I'm a bit stuck with the following. I have three tables:
location, contains cols: locationid (INT) and location (VARCHAR)
school, contains cols: schoolid (INT) and school (VARCHAR)
person, contains lots of cols, including locationid and schoolid.
But with the query below, how do I change the last two lines to echo the location name and school name rather than their IDs? Is it some kind of join?
The URL looks like this: results.php?location=3&school=6
$location=$_GET['location'];
$school=$_GET['school'];
$sql = "SELECT * FROM people WHERE locationid='$location' AND schoolid='$school'";
$result=mysql_query($sql);
while($row = mysql_fetch_array($result)) {
echo "Person: {$row['person']}<br />";
echo "Location: {$row['locationid']}<br />";
echo "School: {$row['schoolid']}<br />";
}
Many thanks!!