Min Ko Ko Min Ko Ko - 3 months ago 10
MySQL Question

how to get the result of cart in the model in codeigniter?

My cart have two roomname.I loop the cart to get all value of roomname and want data of the both two roomname in the view.

My Model

public function getextrabedinfo(){


foreach ($this->cart->contents() as $cart) {

$roomname = $cart['roomname'];

$query = $this->db->query("SELECT * FROM roomcalendar where roomname='$roomname' ");

return $query->result();

}}

Answer

According to your question if you want to send data from model to view then try your code in this way..

 public function getextrabedinfo(){

$alldata = array();
    foreach ($this->cart->contents() as  $cart) {

        $roomname = $cart['roomname']; 

        $query = $this->db->query("SELECT * FROM roomcalendar where roomname='$roomname' ");

        $alldata[] = $query->result();

    }   
return $alldata ;

}

Try this .. Hope it will work.

Comments