Hi I’m inserting Latitude, Longitude values into the database.
INSERT INTO `Tracks` (`Latitude`, `Longitude`, `Time`, `Date`, `Speed`) VALUES ('$Latitude', '$Longitude', '$UTC_Time', '$UTC_Date', '$Speed');
The gps receiver tends to send the same lat, long values more than once.. Before inserting, i’m trying to check the lat long columns of the last inserted row, and if they match, the query should not be executed. Else the query should be executed. I’m currently unable to do this! What if there are no rows in the database and the code checks for the last inserted row?
Also the user may come to the same location again at a later time and hence we should not check the whole db for duplicate lat, long values. How should I do this then? Can I do this in php itself without checking the db? Any ideas/suggestions? Thanks in advance!
If you use MySQL, one thing I can think of is to change
into
And setting a
PRIMARY KEYwith those two fields (Latitude and Longitude).Since you specified
without checking the dbis the only solution I can think of.If you try to insert an equal pair of
Langitude, LatitudeINSERT IGNOREstatement will be just ignored.