Loop to get mysql values with php codeigniter -


i'm stuck on model side have write loop select values mysql. table looks this:

0      2016-11-06 08:36:19  7300   2016-11-06 08:43:11  19200  2016-11-06 08:43:12  35980  2016-11-06 08:43:17  45600  2016-11-06 08:43:21  45820  2016-11-06 08:43:27  45840  2016-11-06 08:43:28  45860  2016-11-06 08:43:29  26940  2016-11-06 08:44:34  19760  2016-11-06 08:44:36  3440   2016-11-06 08:44:38  0      2016-11-06 08:44:44  1400   2016-11-06 08:46:00  7120   2016-11-06 08:46:04  11240  2016-11-06 08:46:06  11220  2016-11-06 08:46:10  11240  2016-11-06 08:46:11  11220  2016-11-06 08:46:12  3940   2016-11-06 08:46:51  0      2016-11-06 08:46:56

basically entries generated weighting machine , inserted in database works :

when on weighing machine, entries start update 0 real weight of object on weight machine, till real weight values going up. when difference on 3-4 entries less 50kg, @ real weight. weight drop 0 again, , start same cicle when on it. above example, these entries interested in:

45840  2016-11-06 08:43:28  11220  2016-11-06 08:46:10

i thinking compare each entry following one, , when difference less 50 kg 3 entries, 1 of entries , continue other ones, don't how can in php.

$sql = "select weight, added_date balance_events added_date between '".$from_date."' , '".$to_date."'";            $query = $this->db->query($sql);            $result = $query->result();            weight in result:            // loop            return $result;

how make loop in order desired output? there way check timestamp on added_date in order constrain time of weight event (0 0) more 5 minutes, , ignore ones have duration under 5min?

here query values loop , condition above 5 minutes.

       $sql = "select weight, added_date, minute(added_date) minute balance_events added_date between '".$from_date."' , '".$to_date."'";                   $query = $this->db->query($sql);                   foreach($query->result() $row){                       if($row->minute > 5){                           echo $weight=$row->weight;                           echo $added_date=$row->added_date;                       }                   } 

Comments

Popular posts from this blog

php - How to add and update images or image url in Volusion using Volusion API -

javascript - jQuery UI Splitter/Resizable for unlimited amount of columns -

javascript - IE9 error '$'is not defined -