Deleting old data from mySQL
Hi,
haven't posted here in a while, but just started using some PHP for a mySQL database.
I have a microprocessor that uploads data to a mySQL via php.
At the moment the database adds an entry for every piece of data sent, so basically the id is incremented each time.
Due to the amount of data being processed, this database is going to get pretty big rather quickly.
I have posted the current php script below.
How would I go about, and is it possible, to store 7 days worth of data and then start overwriting the data on day 8 again for example, therefore I only effectively have 1 weeks worth of data.
I am very new to PHP & mySQL, so go easy :-)
I would also like to store time as GMT (UK time).
Hope all this makes sense and any help or guidance is appriciated !
Steve
PHP Code:
<?php
// connect to MySQL
mysql_connect('server','user','password') or die("Can't connect that way!");
@mysql_select_db('arduino') or die("Unable to select a database called 'Arduino'");
if(ISSET($_GET['t']) && (is_numeric($_GET['t'])) && $_SERVER['REMOTE_ADDR']=='192.168.1.142'){
// message from the Arduino
$temp = $_GET['t'];
$date = date("Y-m-d H:i:s"); //echo "\n";
$qry = "INSERT INTO temp(timing, temp) VALUES('$date','$temp')";
mysql_query($qry);
mysql_close();
exit('200');
}
mysql_close();
?>