I'm trying to retrieve information from a database that has Names of people their ID and the locations they live with the location's ID(fictional example). The way I have it set up I have to link the tables together so I figured I might as well retrieve ALL the information I need in 1 MySQL query. Which came out to something like this.(except instead of it selecting stuff from one table it was selecting and LEFT JOINING from all kinds of tables)
peopleQ = mysql_query("SELECT name, location, locationID, peopleID FROM people;", $link);
I want the page to display the names and locations, as links, when you click the links they go to a different page with a GET Variable as their ID and display extra information on those things. Then with that information I'd like to display something like.
<a href='/people.php?id=1'>Sally</a>
<a href='/people.php?id=2'>Jimmy</a>
<a href='/people.php?id='3'>Cindy</a>
And then...
<a href='/location.php?id=45'>Miami</a>
<a href='/location.php?id=46'>New York</a>
<a href='/location.php?id='46'>Boston</a>
I was wondering if anyone had a solution or could point me to documentation for storing all those things as arrays and having them print like that. Because most of the tutorials and stuff are all geared for doing this with 1 set of arrays not 4. I know the really simple solution for this would be to make 4 seperate queries, but I feel that if I can pull all the information easily with 1 query why pound my DB in the butt with 4 seperate queries that all do and link to the same tables.