time-recods table i have
date
time in
time out
break in
break out
total_time
fields in my table. i have this sql query
public function showattendance(){
$start = $this->input->post('DATE_FROM');
$end = $this->input->post('DATE_TO');
$employee = $this->input->post('ID_NUM');
$sql = "SELECT * FROM `attendance` WHERE (DATE BETWEEN '".$start."' AND '".$end."') AND (ID_NUM = '".$employee."')";
$query = $this->db->query($sql);
return $query->result();
}
now all i want to do is when i already selected the rows between the dates i chose, i wanted to add the selected data from total_time
column.
for example i got an array of
array = (
ID[0] => '1' , TOTAL_TIME[0]=>'09:30'
ID[1] => '2' , TOTAL_TIME[1]=>'07:30'
ID[2] => '3' , TOTAL_TIME[2]=>'08:30'
ID[3] => '4' , TOTAL_TIME[3]=>'09:00'
ID[4] => '5' , TOTAL_TIME[4]=>'05:45'
);
all i want to do is to add
TOTAL_TIME[0]+TOTAL_TIME[1]+TOTAL_TIME[2]+TOTAL_TIME[3]+TOTAL_TIME[4] = $value
It gets pretty simple to do so when you convert your result into array.. This might help you out from your problem.
Here one column is later updated with new values in php. This may be helpful.
-------------- Updated Answer ------------
Then your array should be like
<?php
$x = array(
array( ID => '1' , TOTAL_TIME =>'09:30'),
array( ID => '2' , TOTAL_TIME =>'07:30'),
array( ID => '3' , TOTAL_TIME =>'08:30'),
array( ID => '4' , TOTAL_TIME =>'09:00'),
array( ID => '5' , TOTAL_TIME =>'05:45'));
$total;
foreach($x as $y){
$total+=$y["TOTAL_TIME"];
}
echo "Total Time = ".$total;
?>
Thus you can get your total time.