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
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!

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.