id timing temp temp1 temp2 temp3
5260 1446746934 -76 -15 4 25
5259 1446746332 -75 -14 5 25
5258 1446745731 -77 -15 6 25
I have database like this. And I wrote the code below to get the row value out from my database. I would like to get the data from the previous points. Right now, I only get the latest point -76 from temp column. How to get the data from previous points like -75 or -77 at one column ??
$qryd = "SELECT id, timing, temp,temp1,temp2,temp3 FROM tempArray WHERE timing>='$dlimit' ORDER BY id ASC LIMIT 1008;
$i=0;
$r = mysql_query($qryd);
$count = mysql_num_rows($r);
while($row=mysql_fetch_array($r, MYSQL_ASSOC)) {
$tid=$row['id'];
$dt = $row['timing'];
$te = $row['temp'];
$return="[$dt, $te],";
echo $return;
$i++;
}
echo $te;
//the result is -76