So i am generating a XML file based on data from mysql tables but need to be able to get the data i want from 2 tables using my query and unsure how to do this. details are as follows:
TABLE: store_locations
===================================
store_location_id
country
latitude
longitude
===================================
TABLE: store_locations_descriptions
===================================
store_location_id
name
description
city
===================================
PHP Function:
// Function to generate XML file based on store data from database
function fn_store_locator_generate_xml(){
$qur = db_get_field("JOIN QUERY WANTED HERE");
$ans=mysql_query($qur);
$output.= "<?xml version=\"1.0\" encoding=\"UTF-8\"?>
<kml xmlns=\"http://earth.google.com/kml/2.2\">
<Document>";
while($row=mysql_fetch_array($ans))
{
$output.="<name>".$row['name']."</name>";
$output.="<description>".$row['description']."</surname>";
$output.="<Placemark>";
$output.="<name>".$row['name']."</name>";
$output.="<Snippet>".$row['description']."</Snippet>";
$output.="<description>".$row['description']."</description>";
$output.="<Point>";
$output.="<coordinates>".$row['latitude'].",".$row['longitude']."</coordinates>";
$output.="</Point>";
$output.="</Placemark>";
$output.="</person>";
}
$output.="</Document>";
$file_name = "galleries.xml";
$file_pointer = fopen($file_name, "w+");
fwrite($file_pointer, "$output");
fclose($file_pointer);
}
// generate the XML file
fn_store_locator_generate_xml();
Many Thanks in advance!
Looks like you just need a join. I’m assuming you have 1 to 1 relationship between these tables.
You should certainly look into how joins work:
http://www.keithjbrown.co.uk/vworks/mysql/mysql_p5.php