php - Codeigniter getting multiple data in foreach in controller -
i have problem regarding foreach loop wherein cannot access first array or array[0] , dont know problem.
here controller:
$this->sessioncheck(); $this->user->initialize($this->session->userdata('userid')); $this->load->model('project_model', 'project'); $projectid = $this->input->post('projectid'); /***************** intialize project model ******************/ $this->project->initialize($projectid); $options = work_breakdown_structure::$withbasetaskid; //$phasetaskid = (int)$this->input->get_post('taskid',true); $phasetaskid = $this->project->getphasebasetaskid($projectid); $postlist->phasetaskid = $this->project->getphasebasetaskid($projectid); $postlist->phaselist = $this->project->latestapplicableplan->wbs->getphaselist($options); if($phasetaskid == null) { } else { foreach($phasetaskid $index=>$value) { $finalarr[$value['taskname']] = $value['basetaskid']; $postlist->tasklist = $this->project->latestapplicableplan->wbs->getwbs($finalarr[$value['taskname']], $options); } echo print_r($finalarr); for($x = 1 ; $x < 2 ; $x++) { //$postlist->tasklist = $this->project->latestapplicableplan->wbs->getwbs($phaseid, $options); } } $postlist->project = $projectid; return $this->load->view('mytodophasedropdown', $postlist);
here view:
echo '<td style="padding-top:5x;font-size:14px;" colspan="2"> <br> phases : '; echo '<select id="phases_select" style="width:400px;" onchange="search_filter()" >'; echo '<option value="0" selected="selected"> select project phase </option>'; foreach($phaselist $row) { if(preg_match("/^cycle/", strtoupper($row['taskname']))) { foreach($row['child'] $child) { echo '<option value="'. $child['taskid']. '">'; echo $row['taskname'].' > '.$child['taskname'] . '</option>'; } } else { if($iterate['basetaskid'] != $row['taskid']) { echo '<option value="'. $row['taskid']. '">'; echo $row['taskname'].'</option>'; } foreach($tasklist $iterate) { if($row['taskid'] == $iterate['basetaskid'] ) { echo '<option value="'. $row['taskid']. '">'; echo $iterate['taskname'].' '.$iterate['iterationnumber']. '</option>'; } } } } echo '</select>'; echo '</td>';
the problem need values array pass view. latest value 2nd data retrieve in database.
what doing wrong :
return $this->load->view('mytodophasedropdown', $postlist);
you need set data in variable accessible in view : http://codeigniter.com/user_guide/general/views.html
$data = array('title' => 'my title', 'heading' => 'my heading', 'message' => 'my message'); $this->load->view('mytodophasedropdown', $data);
and in view file : mytodophasedropdown.php
<html> <?php //access them echo $title.$heading.$message; ?> </html>
Comments
Post a Comment