Thread: Help!!

    #1
  1. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Dec 2012
    Posts
    33
    Rep Power
    2

    Help!!


    hello!! I am current working with codeigniter! I have this problem that keeps on repeating. I have result array(A) returned from model to controller. and the array result will be used in the view. now when i have two the same loop to access the common data(A) one returns the values ok. but the other one returns letters and numbers that is wrong and from out of nowhere. can somebody help me. thank you!
  2. #2
  3. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Dec 2012
    Posts
    165
    Rep Power
    18
    Post your source code please. What is the data type of the arrays?
    Originally Posted by bads
    hello!! I am current working with codeigniter! I have this problem that keeps on repeating. I have result array(A) returned from model to controller. and the array result will be used in the view. now when i have two the same loop to access the common data(A) one returns the values ok. but the other one returns letters and numbers that is wrong and from out of nowhere. can somebody help me. thank you!
  4. #3
  5. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Dec 2012
    Posts
    33
    Rep Power
    2
    Thanks for the reply! Here is my model.
    PHP Code:
    public function get_Hours() { $this->load->database(); $query $this->db->get('hours'); return $query->result_array(); } 
    Here is my controller.

    PHP Code:
    function viewSchedules(){ $this->load->model('pms/Schedule_model'); $this->load->model('pms/Room_model'); $this->load->model('pms/Hour_model'); $this->load->helper('form'); $this->load->library('form_validation'); $this->load->library('javascript'); $data['base'] = $this->config->item('base_url'); $data['css'] = $this->config->item('css'); $data['lname'] = $this->session->userdata('ulname'); $data['fname'] = $this->session->userdata('ufname'); $data['utype'] = $this->session->userdata('utype'); $data['datetoday'] = date("Y-m-d"); $rooms $this->multiSorter($this->Room_model->get_Rooms(),'roomname'); $hours $this->Hour_model->get_Hours(); $schedules $this->multiSorter($this->Schedule_model->get_Schedulestoday(),'scheddate'); $therapists $this->Schedule_model->get_therapists(); $data['schedules'] = $schedules$data['hours'] = $hours$data['rooms'] = $rooms$data['therapists'] = $therapists$this->load->view('pms/viewSchedules'$data); }"]function viewSchedules(){ $this->load->model('pms/Schedule_model'); $this->load->model('pms/Room_model'); $this->load->model('pms/Hour_model'); $this->load->helper('form'); $this->load->library('form_validation'); $this->load->library('javascript'); $data['base'] = $this->config->item('base_url'); $data['css'] = $this->config->item('css'); $data['lname'] = $this->session->userdata('ulname'); $data['fname'] = $this->session->userdata('ufname'); $data['utype'] = $this->session->userdata('utype'); $data['datetoday'] = date("Y-m-d"); $rooms = $this->multiSorter($this->Room_model->get_Rooms(),'roomname'); $hours = $this->Hour_model->get_Hours(); $schedules = $this->multiSorter($this->Schedule_model->get_Schedulestoday(),'scheddate'); $therapists = $this->Schedule_model->get_therapists(); $data['schedules'] = $schedules$data['hours'] = $hours$data['rooms'] = $rooms$data['therapists'] = $therapists$this->load->view('pms/viewSchedules', $data); } 
    Here is view. I have to use the same data in 2 foreach loop. but the other returns 1, R, A and dont know where they came from.

    1.
    PHP Code:
    <div class="input" id="selectroom"> Select Room: <select class = "input" id="room" name="room"> <option></option> <option> All Rooms </option> <?php if (is_array($rooms)){ foreach ($rooms as $rooms) { echo "<option>" $rooms['roomname'] ."</option>"; } } ?> </select> </div>
    2.
    PHP Code:
    <div class="input" id="selectroom2"> Select Room: <select class = "input" id="room2" name="room2"> <option></option> <option> All Rooms </option> <?php foreach ($rooms as $rooms) { echo "<option>" $rooms['roomname'] ."</option>"; } ?> </select> </div>
    Sorry hard up wrapping them. =)
    Last edited by bads; January 6th, 2013 at 03:01 AM. Reason: Wrong wrapping
  6. #4
  7. No Profile Picture
    Contributing User
    Devshed Novice (500 - 999 posts)

    Join Date
    Jun 2009
    Posts
    721
    Rep Power
    7
    Just a side note for pasting code. Copy n paste from your text editor into here, and wrap in PHP tags. DO NOT use the pop-up when entering your coding.

IMN logo majestic logo threadwatch logo seochat tools logo