2

I'm trying to make a web based tracking system with a GPS that can be controlled by sending SMS.

How my system work: When user clicks a button to know the GPS location, the system send an SMS (with certain format) by SMS gateway to the GPS device. The GPS will reply with its coordinate by SMS too. After that, the location information of the GPS such as latitude, longitude, and etc will be taken from the SMS with a function and a trigger (I already make it and it works) and the data will be inserted automatically to a table named tb_history. I want to display the newest location data that just inserted to the table with this query:

SELECT * FROM tb_history WHERE tb_history.`id_gps`='1' AND tb_history.`date`='2014-04-24' ORDER BY tb_history.`time` DESC LIMIT 1;

my question is, is there a way I can run this code automatically after a data just inserted to the tb_history? my teacher say that maybe I can use a javascript that always refresh the page and stop refreshing if there was a data inserted to tb_history??? I really need an example to understand it...

I forgot to mention that I made my system with PHP and javascript

sorry for the bad english and Thank you for those who gave me the answer...

user3581186
  • 37
  • 1
  • 7

2 Answers2

1

Use mysql trigger for this purpose http://dev.mysql.com/doc/refman/5.1/de/create-trigger.html

xyNNN
  • 492
  • 3
  • 21
0

From your edited question I would guess you are confusing the CGI-script on the server that you implement in PHP with the webpage, generated by the PHP-script on the server and, loaded by the client that should be using Javascript to get an update from the server when the SMS returns from your application on the telephone.

Mister Henson gave you keywords for two good google searches about how the Javascript can learn about when the returned SMS arrives.

Two hits on the google search lead to this site:

Community
  • 1
  • 1
Samuel Åslund
  • 2,814
  • 2
  • 18
  • 23