我是 codeigniter 的新手,我使用的是 2.1.3_2 版本
我想将单行从模型发送到控制器,然后从控制器发送到视图。我检查了一些前面讨论过的相同类型的问题,但无法解决它
我的控制器的代码是
public function updateq()
{
$qid1=$this->input->get('qid',true);
$showd['data1']=$this->quiz_model->updateq($qid1);
$this->load->view('Quiz/update',$showd);
}
模型代码是
public function updateq($qid1)
{
$this->db->where('qid',$qid1);
$up=$this->db->get('question');
return $up->row();
}
现在视图的代码是
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title>Untitled Document</title>
</head>
<body>
<?php echo form_open('quiz/update');
?>
<table width="77%" height="327" align="center" border="1">
<tr>
<td height="39" colspan="2" align="center">
<h2> update your Question Here</h2>
</td>
</tr>
<tr>
<td width="97">Question</td>
<td width="287"><textarea name="question" id="textarea" cols="45" rows="2" required="required" value="<?php echo $data1->question;?> "></textarea></td>
</tr>
<tr>
<td colspan="2"> </td>
</tr>
<tr>
<td>Option 1 :</td>
<td><textarea name="option1" id="textarea3" cols="45" rows="2" required="required" value="<?php echo $data1->option1 ;?> "></textarea></td>
</tr>
<tr>
<td>Option 2 :</td>
<td><textarea name="option2" id="textarea4" cols="45" rows="2" required="required"value="<?php echo $data1->option2;?> "></textarea></td>
</tr>
<tr>
<td>Option 3: </td>
<td><textarea name="option3" id="textarea5" cols="45" rows="2" required="required"value="<?php echo $data1->option3;?> "></textarea></td>
</tr>
<tr>
<td>Option 4:</td>
<td><textarea name="option4" id="textarea6" cols="45" rows="2" required="required"value="<?php echo $data1->option4;?> "></textarea></td>
</tr>
<tr>
<td>
<label for="select2">Correct Answer</label></td>
<td><select name="ra" id="select2">
<option value="Select Correct option">Select Correct option</option>
<option value="option1">option1</option>
<option value="option2">option2</option>
<option value="option3">option3</option>
<option value="option4">option4</option>
</select></td>
</tr>
<tr>
<td colspan="2"><input type="submit" name="button1" id="button2" value="Submit Question &ans; Answer" /></td>
</tr>
</table>
</body>
</html>
我检查了查询是否返回一行。但我不明白为什么我的视图中出现空白文本框。