I have the db having the location log of the vehicle which means every coordinates will be stored in the db. Now for vehicle 1, assume there are 30 entries in the table, meaning 30 locations. Now when the 31st entry comes, i want the FIRST entry to get removed which means, the maximum numbers of location log per vehicle should be 30.
Right now the insert query is
mysqli_query($con,
"INSERT INTO $location_history
VALUES('$id','$lat','$lng','$pwd','$v1','$v2','$v3','$v4','$status' )")
or die("Count not insert to location history!");
You should use a trigger function that is going to work on every insert, count the entries, and if there are more than 30, delete the oldest ones until there are less than 30 entries.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With