0
您好,我想在表格中插入從下拉菜單中選擇的值以及先前創建的用戶的值。當我進行插入時,只有插入到表格中的值纔會從下拉列表中選擇。但其他值不會被插入。請幫幫我。這是代碼。PHP和下拉菜單插入錯誤
$query= "INSERT INTO employee (UserName, Password, Name, LastName, " .
"Email, Phone, Classification_ClassificationID) VALUES" .
" ('$user1', SHA('$password1'),'$name', '$lastname', '$email', " .
" '$phone_number', '$classification_id')";
queryMysql($query);
echo '<p>Account Created.</p>';
echo $user1;
}
echo '<h1> Grupo Asignado:</h1>' ;
if (isset ($_POST['submit'])){
foreach ($_POST['toinsert'] as $insert_id) {
$query = "INSERT INTO groupusers (GroupsID, Employee_UserName) Values ('$insert_id', '$user1')" ;
queryMysql($query);
echo mysql_num_rows($result);
echo '<br />';
}
}
$query = "SELECT * FROM employeegroups";
$result = queryMysql($query);
while ($row = mysql_fetch_array($result)) {
echo '<input type="checkbox" value="' .$row['GroupsID'] . '" name="toinsert[]" />';
echo $row['GroupName'];
echo '<br />';
}
echo '<input type="submit" name="submit" value="Insert" />';
echo '</form>';
echo '</body>';
echo '</html>';
?>
請格式化您的代碼。請。 – 2011-01-19 00:20:59