我是codeigniter的新手,我正在尝试在网页上显示一些数据我有控制器和模型但是我的变量daunt似乎被传递到视图页面看看我的代码,如果你能告诉我什么是错的用它 tnx 为您提供帮助。
控制器:
class Survaycontroller extends CI_Controller{
// 'QID, Question, qA, qB, qC'
function index()
{
$arrData = array();
$arrData["qA"] = $this->input->post("qA");
$arrData["qB"] = $this->input->post("qB");
$arrData["qC"] = $this->input->post("qC");
$arrData["Question"] = $this->input->post("Question");
$this->load->model('survay');
$survay_data = $this->survay->dosurvay($arrData);
$viewData['survay_data'] = $survay_data;
$this->load->view('survay_view', $viewData);
}
}
看法:
<html>
<body>
<?php form_open('survay'); ?>
<h1><?php echo $Question;?></h1>
<?php echo $qA; ?><input type="checkbox" name="q" value="qA">
<?php echo $qB; ?><input type="checkbox" name="q" value="qB">
<?php echo $qC; ?><input type="checkbox" name="q" value="qC">
<?php echo form_close(); ?>
</body>
</html>
模型:
function dosurvay($arrData){
$this->db->select('QID, Question, qA, qB, qC');
$this->db->from('tblquestions');
$this->db->where('Question', $arrData['Question']);
$this->db->where('qA', $arrData['qA']);
$this->db->where('qB', $arrData['qB']);
$this->db->where('qC', $arrData['qC']);
$this -> db -> limit(1);
$query = $this -> db -> get();
if($query -> num_rows() == 1)
{
return $query->result();
}
else
{
return false;
}
}
}