我有很多复选框,应该向MySQL发送两个值。但是,我没有得到正确的价值。
<?php
if ($_SERVER['REQUEST_METHOD'] == 'POST') {
if ($rootWord != "") {
$tag = "janaan";
$imbuhan = array();
// Imbuhan Kata Nama
$result_awalan_ke = awalan_ke($rootWord, $tag);
$imbuhan[1] = array('imbuhan' => $result_awalan_ke[0], 'pos' => $result_awalan_ke[2]);
$resultDummy = mysql_query("SELECT * FROM tabletruefalse WHERE rootWord ='$result_awalan_ke[0]'");
$exist = mysql_fetch_array($resultDummy, MYSQL_BOTH);
if ($exist) {
echo '<tr><td>'.$result_awalan_ke[1] .' : '. $result_awalan_ke[0] . '</td><td>'. $result_awalan_ke[2].'</td><td>    <input type="checkbox" name="imbuhan[]" value="1" /></td></tr></br>';
}
$result_awalan_pe = awalan_pe($rootWord, $tag);
$imbuhan[2] = array('imbuhan' => $result_awalan_pe[0], 'pos' => $result_awalan_pe[2]);
$resultDummy = mysql_query("SELECT * FROM tabletruefalse WHERE rootWord ='$result_awalan_pe[0]'");
$exist = mysql_fetch_array($resultDummy, MYSQL_BOTH);
if ($exist) {
echo '<tr><td>'.$result_awalan_pe[1] .' : '. $result_awalan_pe[0] . '</td><td>'. $result_awalan_pe[2].'</td><td>    <input type="checkbox" name="imbuhan[]" value="2" /></td></tr></br>';
}
?>
相反,我得到了复选框的值。例如。 1或2。
下面是MySQL代码的插入:
<?php
if(isset($_POST['imbuhan'])){
foreach($_POST['imbuhan'] as $value){
$insert = mysql_query("INSERT INTO tablebyuser(rootWord, posWord)
VALUES ('$value[imbuhan]', '$value[pos]')");
}
}
?>