Hi all

I followed this tutorial Creating a Store Locator with PHP, MySQL & Google Maps to create a store locator and it works great.

I need to now select columns from another table and needed some guidance.

This is the code:

PHP Code:
// Search the rows in the markers table
$query sprintf("SELECT primarykey, address, postcode, lat, lng, ( 3959 * acos( cos( radians('%s') ) * cos( radians( lat ) ) * cos( radians( lng ) - radians('%s') ) + sin( radians('%s') ) * sin( radians( lat ) ) ) ) AS distance FROM markers HAVING distance < '%s' ORDER BY distance LIMIT 0 , 5",
  
mysql_real_escape_string($center_lat),
  
mysql_real_escape_string($center_lng),
  
mysql_real_escape_string($center_lat),
  
mysql_real_escape_string($radius));
$result mysql_query($query);

$result mysql_query($query);
if (!
$result) {
  die(
"Invalid query: " mysql_error());
}

// Start XML file, echo parent node
echo "<markers>\n";

while (
$row = @mysql_fetch_assoc($result)){
  
// ADD TO XML DOCUMENT NODE
  
echo '<marker ';
  echo 
'id="' parseToXML($row['primarykey']) . '" ';
  echo 
'address="' parseToXML($row['address']) . '" ';
  echo 
'postcode="' parseToXML($row['postcode']) . '" ';
  echo 
'lat="' $row['lat'] . '" ';
  echo 
'lng="' $row['lng'] . '" ';
  echo 
'distance="' $row['distance'] . '" ';
  echo 
"/>\n";

I now have a table called "products" with a Primary key. From this table I need 2 columns.

How would I go about retrieving the data from the second table WHERE markers.primarykey = products.primarykey (and two other columns "col1" and "col2"). Would I add it in the same query shown above?

Hope someone can help guide me in the right direction?

Many thanks