【发布时间】:2015-08-13 20:03:41
【问题描述】:
我的代码中有这个复选框
<fieldset><legend>What search engine do you prefer?</legend><br><br><br>
<!-- container ko start -->
<div id="container2">
<table>
<tr>
<td width="30%">
<label><img src="images/google.png" height="40px" width="120px"></label>
<input type="checkbox" name="engine1[]" value="google">
</td>
<td width="30%">
<label><img src="images/yahoo.png" height="40px" width="120px"></label>
<input type="checkbox" name="engine1[]" value="yahoo">
</td>
<td width="30%">
<label><img src="images/bing.png" height="40px" width="120px"></label>
<input type="checkbox" name="engine1[]" value="bing">
</td>
</tr>
</table>
</div>
</fieldset>
<br><br><br><br><br>
<fieldset><legend>Put check on the icons that you are familiar with.</legend><br><br><br>
<div id="container2">
<table>
<tr>
<td>
<label><img src="images/fb.png" height="40px" width="40px"></label>
<input type="checkbox" name="engine2[]" value="fb">
</td>
<td>
<label><img src="images/twit.png" height="40px" width="40px"></label>
<input type="checkbox" name="engine2[]" value="twitter">
</td>
<td>
<label><img src="images/googplus.png" height="40px" width="40px"></label>
<input type="checkbox" name="engine2[]" value="googleplus">
</td>
</tr>
<tr>
<td>
<label><img src="images/link.png" height="40px" width="40px"></label>
<input type="checkbox" name="engine2[]" value="linkedin">
</td>
<td>
<label><img src="images/pin.png" height="40px" width="40px"></label>
<input type="checkbox" name="engine2[]" value="pinterest">
</td>
<td>
<label><img src="images/del.png" height="40px" width="40px"></label>
<input type="checkbox" name="engine2[]" value="delicious">
</td>
</tr>
<tr>
<td>
<label><img src="images/stumb.png" height="40px" width="55px"></label>
<input type="checkbox" name="engine2[]" value="stumbleupon">
</td>
<td>
<label><img src="images/diig.png" height="40px" width="40px"></label>
<input type="checkbox" name="engine2[]" value="diigo">
</td>
</tr>
</table>
</div>
<!-- container ko end -->
</fieldset>
两个集合,名称分别为engine1 和engine2。我想通过这段代码使用 implode 将它们插入到我的数据库中..
$_POST['engine1'] = array();
$_POST['engine2'] = array();
$engine1 = implode(',', $_POST['engine1']);
$engine2 = implode(',', $_POST['engine2']);
但是每次我检查我的数据库表时,这些列都是空的。 你认为我做错了什么?请帮忙!
【问题讨论】:
-
你为什么要初始化 $_POST['engine1'] = array(); $_POST['engine2'] = array();
标签: php database checkbox implode