我的购物车有两个房间名。我循环购物车以获取房间名的所有值,并希望视图中两个房间名的数据。
我的模特
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();
}}
答案 0 :(得分:1)
根据您的问题,如果您想将数据从模型发送到视图,请以这种方式尝试您的代码..
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 ;
}
试试这个..希望它能奏效。