Jump to content

Query Returns Double Results


sintax63

Recommended Posts

I have no idea why but this query is returning double results for each item.

 

<marker id="1".... />
<marker id="1".... />
<marker id="2".... />
<marker id="2".... />

 

... etc. Any ideas why that might be?

 

<?php

// Select all the rows in the markers table
$query = "SELECT * FROM profiles, geocode, users, tracking WHERE geocode.id = profiles.id AND profiles.id = tracking.placeID AND tracking.userID ='$profileID' ORDER BY 'id' ASC";
$result = mysql_query($query);
if (!$result) {
  die('Invalid query: ' . mysql_error());
}

header("Content-type: text/xml");

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

// Iterate through the rows, printing XML nodes for each
while ($row = @mysql_fetch_assoc($result)){
  // ADD TO XML DOCUMENT NODE
  echo '<marker ';
  echo 'id="' . parseToXML($row['id']) . '" ';
  echo 'lat="' . $row['lat'] . '" ';
  echo 'lng="' . $row['lng'] . '" ';
  echo 'address="' . parseToXML($row['address']) . '" ';
  echo 'city="' . parseToXML($row['city']) . '" ';
  echo 'state="' . parseToXML($row['state']) . '" ';
  echo 'zip="' . parseToXML($row['zip']) . '" ';
  echo '/>' . "\n";
}

// End XML file
echo '</markers>';

?>

 

 

Link to comment
https://forums.phpfreaks.com/topic/191962-query-returns-double-results/
Share on other sites

Wow, thanks for the tip! That worked a treat and took care of the double returns as well!

 

For future reference:

$query = "SELECT * FROM profiles, geocode, tracking WHERE geocode.id = profiles.id AND profiles.id = tracking.placeID AND tracking.userID ='$profileID' ORDER BY 'profiles.id' ASC";

 

Cheers, mate!

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.