level 1
掌心烟花
楼主
add.html
<form method="post" action="" enctype="multipart/form-data" >
<table cellspacing="1" cellpadding="3" width="100%">
<tr>
<td colspan="2" align="center">
名称:
<input type="text" name="name[]" maxlength="60" value="" />
价格:
<input type="text" name="price[]" maxlength="60" value="" />
</td>
</tr>
<tr>
<td colspan="2" align="center">
名称:
<input type="text" name="name[]" maxlength="60" value="" />
价格:
<input type="text" name="price[]" maxlength="60" value="" />
</td>
</tr>
<tr>
<td colspan="2" align="center">
名称:
<input type="text" name="name[]" maxlength="60" value="" />
价格:
<input type="text" name="price[]" maxlength="60" value="" />
</td>
</tr>
<tr>
<td colspan="2" align="center"><br />
<input type="submit" class="button" value=" 确定 " />
<input type="reset" class="button" value=" 重置 " />
</td>
</tr>
</table>
</form>
控制器代码:
public function add(){
if(IS_POST){
$authModel = M('admin');
$add['name'] = $_POST['name'];
$add['price']= $_POST['price'];
dump($add);
if($authModel->addAll($add)){
$this->success('添加成功!');
}else{
$this->error('添加失败!');
}
}else{
$this->display();
}
}
报错:

2016年01月18日 14点01分
1
<form method="post" action="" enctype="multipart/form-data" >
<table cellspacing="1" cellpadding="3" width="100%">
<tr>
<td colspan="2" align="center">
名称:
<input type="text" name="name[]" maxlength="60" value="" />
价格:
<input type="text" name="price[]" maxlength="60" value="" />
</td>
</tr>
<tr>
<td colspan="2" align="center">
名称:
<input type="text" name="name[]" maxlength="60" value="" />
价格:
<input type="text" name="price[]" maxlength="60" value="" />
</td>
</tr>
<tr>
<td colspan="2" align="center">
名称:
<input type="text" name="name[]" maxlength="60" value="" />
价格:
<input type="text" name="price[]" maxlength="60" value="" />
</td>
</tr>
<tr>
<td colspan="2" align="center"><br />
<input type="submit" class="button" value=" 确定 " />
<input type="reset" class="button" value=" 重置 " />
</td>
</tr>
</table>
</form>
控制器代码:
public function add(){
if(IS_POST){
$authModel = M('admin');
$add['name'] = $_POST['name'];
$add['price']= $_POST['price'];
dump($add);
if($authModel->addAll($add)){
$this->success('添加成功!');
}else{
$this->error('添加失败!');
}
}else{
$this->display();
}
}
报错:
