<form action="4.php" method="POST">
<select name="select2[]" multiple>
<option value="volvo">Volvo</option>
<option value="saab">Saab</option>
<option value="opel">Opel</option>
<option value="audi">Audi</option>
</select>
<select name="select[]" multiple>
<option value="volvo1">Volvo1</option>
<option value="saab2">Saab2</option>
<option value="opel3">Opel3</option>
<option value="audi4">Audi4</option>
</select>
<input type="submit" name="sub" value="submit">
</form>
4.php
<?php
mysql_connect("localhost", "root", "");
$db=mysql_select_db("test");
if(isset($_POST['sub'])) {
$r=$_POST['select2'];
$f=$_POST['select'];
$val1 = implode("", $r);
$val2 = implode("", $f);
$r=mysql_query("insert into test1 (test,test1) values ('$val1','$val2') ");
}
?>
我正在使用 php 语言。我正在使用选择多个并尝试在我的数据库中添加值,但仅在一行中添加所有值