如何使用checkigniter提取复选框信息并将其存储在数据库中

|| 我在php文件中有此代码。它列出了所有感兴趣的内容作为复选框,并允许输入文本字段“其他”。用户应选择其中一些兴趣并保存。现在,当用户单击“提交”按钮时,应将其带到控制器,控制器应提取它们并将其存储在数据库中。我有一个文件被编码为执行此操作,但是它没有好处并且太混乱了。 这是普通php文件中的表格
<form method=\"post\" action=\"<?php echo site_url(\"userProfile/update_bio\");?>\" name=\"editForm\" id=\"edit-form\">

<div> <!-- description start -->
<div> <p <p class=\"special-p\">Name:</p> <hr> </div>
<p class=\"used-p\"> <input type=\"text\" name=\"name\" value=\"<?php echo $this->dx_auth->get_username(); ?>\"></textarea> </p> <!-- should be real name -->

</div> <!-- description end -->

<div> <!-- description start -->
<div> <p <p class=\"special-p\">Description:</p> <hr> </div>
<p class=\"used-p\"> <textarea name=\"description\"></textarea> </p>

</div> <!-- description end -->

<div> <!-- interests start -->
<div> <p class=\"special-p\">Interests:</p> <hr class=\"special-hr2\"> </div>
<p class=\"used-p\">I am interested in:</p>

<ul>
<?php
foreach ($allInterests->result() as $row){
echo \'<li><input type=\"checkbox\" name=\"checks1[]\" value=\"\'.$row->id.\'\"/> \'.$row->name.\'</li>\';


}

?>
<li><input type=\"checkbox\" name=\"checks1[]\" value=\"other\"/> Other: <input type=\"text\" name=\"otherText\"/></li>
</ul>

</div> <!-- interests start -->

<div>
<input id=\"editbutton\" type=\"submit\" value=\"Save\" name=\"editBioButton\" class=\"small green button\"/>
</div>

</form>
控制器功能为空。问题是我不知道它将如何接收复选框。 提前感谢
已邀请:
foreach($this->input->post(checks1) as $check)
{
    echo $check;
}
但是我相信,如果未选中此复选框,它将不会出现在
$_POST
数组中。为了解决这个问题,请为每个复选框指定一个特定的索引:
<?php
$count=0;
foreach ($allInterests->result() as $row){
   echo \'<li><input type=\"checkbox\" 
        name=\"checks1[\' . $count . \']\" value=\"\'.$row->id.\'\"/> \'.$row->name.\'</li>\';
    $count++;
}
可以满足您的要求。您的控制器将是:
foreach($this->input->post(checks1) as $key => $value)
{
    echo $key . \' - \' . $value;
}

要回复问题请先登录注册