我目前正在开展一个项目,我需要在MySQL数据库中保存多个单元。
html设置如下(这是从数据库中使用while循环生成的.0,1,2是由php变量插入的):
@media (min-width: 768px) {
.navbar-toggle {
padding: 33px 10px;
}
}
此信息通过在页面上提交的表单提交。我有以下PHP / MySQL代码来保存它,但遗憾的是它没有工作:
<p>
<input type="checkbox" name="section[0][equal_columns]" value="<?php echo $item['equal_columns']; ?>" style="width: 25px;" /> Blokken even hoog
</p>
<p>
<input type="checkbox" name="section[0][gutter]" value="<?php echo $item['gutter']; ?>" style="width: 25px;" /> Geen tussenruimte kolommen
</p>
<p>
<input type="checkbox" name="section[0][full_width]" value="<?php echo $item['full_width']; ?>" style="width: 25px;" /> Sidewide grid
</p>
<p>
<input type="checkbox" name="section[1][equal_columns]" value="<?php echo $item['equal_columns']; ?>" style="width: 25px;" /> Blokken even hoog
</p>
<p>
<input type="checkbox" name="section[1][gutter]" value="<?php echo $item['gutter']; ?>" style="width: 25px;" /> Geen tussenruimte kolommen
</p>
<p>
<input type="checkbox" name="section[1][full_width]" value="<?php echo $item['full_width']; ?>" style="width: 25px;" /> Sidewide grid
</p>
但查询foreach并未输入输入表单中的值。
我的php也给了我以下错误:
if($_SERVER['REQUEST_METHOD'] == 'POST' && isset($_POST['save'])) {
foreach($_POST['section'] as $index => $value) {
$secquery .= "block_name = '".mysqli_real_escape_string($GLOBALS['core']->mysqli, $value['block_name'])."',
parent_id = '".mysqli_real_escape_string($GLOBALS['core']->mysqli, $uri[3])."',
type_id = '".mysqli_real_escape_string($GLOBALS['core']->mysqli, $value['type_id'])."',
position = '".mysqli_real_escape_string($GLOBALS['core']->mysqli, $value['position'])."',
background_image = '".mysqli_real_escape_string($GLOBALS['core']->mysqli, $value['background_image'])."',
background_color = '".mysqli_real_escape_string($GLOBALS['core']->mysqli, $value['background_color'])."',
padding_top = '".mysqli_real_escape_string($GLOBALS['core']->mysqli, $value['padding_top'])."',
padding_bottom = '".mysqli_real_escape_string($GLOBALS['core']->mysqli, $value['padding_bottom'])."',
margin_top = '".mysqli_real_escape_string($GLOBALS['core']->mysqli, $value['margin_top'])."',
margin_bottom = '".mysqli_real_escape_string($GLOBALS['core']->mysqli, $value['margin_bottom'])."',
gutter = '".mysqli_real_escape_string($GLOBALS['core']->mysqli, $value['gutter'])."',
equal_columns = '".mysqli_real_escape_string($GLOBALS['core']->mysqli, $value['equal_columns'])."',
";
}
$save_sec_query = "INSERT INTO dtm_content_blocks SET ".$secquery." status = '".mysqli_real_escape_string($GLOBALS['core']->mysqli, $_POST['status'])."'";
}
我希望现在有足够的信息。如果需要,我可以提供更多,但我无法理解这一点。