2 回答
TA贡献1796条经验 获得超7个赞
仅当您采用另一个隐藏文本字段时,您的 'qstn_id' 将是有价值的。将此字段放入数组中。
在进行 foreach 循环的编码部分中,您必须将 qstn_id 设为“[key]”格式,否则您无法找到跳过的记录。
例如。:
foreach ($que as $key => $ansValue) {
$val2 = $ansValue[$key];
}
// $val2 store as your output.
TA贡献1842条经验 获得超13个赞
这是使用 json_encode 保存数据的代码。让我知道您收到我没有运行此代码的任何错误。
查看文件
<form action="<?php echo base_url()?>Quiz/add_stu_ans" method="POST">
<label>Who is usa president</label>
<input type="text" name="usa_president">
<label>Dhoni is cricket player player</label>
<input type="radio" name="cricket_player" value="True">True
<input type="radio" name="cricket_player" value="False">False
<label>Which is asian country</lable>
<input type="checkbox" name="country[]" value="newyork">newyork
<input type="checkbox" name="country[]" value="india">india
<input type="checkbox" name="country[]" value="srilanka">srilanka
</form>
控制器
public function add_stu_ans()
{
$usa_president = $this->input->post('usa_president');
$cricket_player= $this->input->post('cricket_player');
$country= $this->input->post('country');
$final_data = array(
'usa_president' => $usa_president,
'cricket_player' => $cricket_player,
'country' => $country,
);
$json_encode_data = json_encode($final_data);
$this->Common_model->insert_record('student',$json_encode_data);
$this->session->set_flashdata('message_name' , 'Your Data is Inserted');
redirect('Quiz/question');
}
请在您从数据库中获取数据的最后和时间检查这一点,然后您需要从函数 json_decode 传递该返回数据。
$json_decode_data = json_decode($return_data_from_data_table);
- 2 回答
- 0 关注
- 194 浏览
添加回答
举报
