Hi,
First posting here, so be gentle :-) I have just started using some PHP for a mySQL database.
I have a microprocessor that uploads data to a mySQL via php. The database is basically recording temperature values.
What i need is that the database ONLY contains 7 days worth of data to ensure it doesn't grow too large.
At the moment, I only call the last recorded temperature. However, as my experience with PHP and mySQL grows, I may decide to call the last 24hrs worth of data for example, so having historical data could be useful. But do not need it past the 7 days.
At the moment the database adds an entry for every piece of data sent, so 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 would also like to store time as GMT (UK time).
Hope all this makes sense and any help or guidance is appriciated !
Steve
<?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();
?>