here model. i'm not sure i'm on right track, start. have survey form on website , of values numeric in int fields. want compute average of each of 10 columns. rather computing each result separately, wondering if there way use loop process results. here is:
function survey_averages() { $q = array( '1' => 'q1', '2' => 'q2', '3' => 'q3', '4' => 'q4', '5' => 'q5', '6' => 'q6', '7' => 'q7', '8' => 'q8', '9' => 'q9', '10' => 'q10' ); ($i=1; $i<11; $i++) { $this->db->select_avg($q[$i]); $query[$i] = $this->db->get('survey'); } return $query; }
if i'm on right track, how results of array? if i'm on wrong track, need change? also, if in controller:
foreach($query->result_array() $row) {
how return rows of array? php not letting me $row->1 or $row->'1'.
try var_dump($query->result_array())
Comments
Post a Comment