在普通 PHP 中,您可以在同一页面上发送表单:
<form action = "" method = "POST">
<input type = "text" name = "hi" value = "hi"/>
<input type = "submit" name = "send" value = "Send"/>
</form>
<?
if (isset($_POST['send']))
echo $_POST['hi'];
?>
如何在 CodeIgniter 中做到这一点?
我试过这个,但我不知道该怎么做:
看法:
<? echo form_open('form'); ?>
.....
</form>
<?
if (isset($_POST['data'])){
$array = $data;
foreach ($array as $array){
echo array_sum($array)/count($array)."<br>";
}
}
?>
控制器:
function index() {
$name = $this->input->post('select');
$this->load->model('select');
$data['result'] = $this->select->index();
$this->load->view('theview', $data);
}