sintax63 Posted February 13, 2010 Share Posted February 13, 2010 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>'; ?> Quote Link to comment Share on other sites More sharing options...
mapleleaf Posted February 13, 2010 Share Posted February 13, 2010 Your query isn't using the users table so you can remove that and also the order by won't know which id to order by unless you specify a table. That may not be why things are coming twice but it might help Quote Link to comment Share on other sites More sharing options...
sintax63 Posted February 13, 2010 Author Share Posted February 13, 2010 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! Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.