在这段代码中,当我从下拉列表中选择多个值时,它存储在一行中,但我喜欢在每一行中应用值,所以请任何人帮助我。实际结果:
id game
1. cricket,football,tennis
预期结果:
id game
1 cricket
2 football
代码 -
<html>
<body>
<?php
if(isset($_POST['submit']))
{
$query=mysql_connect('localhost','root','');
mysql_select_db("freeze",$query);
$choice=$_POST['game'];
$choice1=implode(',',$choice);
mysql_query("insert into tb values('','$choice1')");
}
?>
<form method="post" action="multipleselect.php">
Select your favourite game:<br/>
<select name="game[]" multiple="multiple">
<option>Football</option>
<option>Volleyball</option>
<option>Badminton</option>
<option>Cricket</option>
<option>Cricket1</option>
<option>Cricket2</option>
<option>Cricket3</option>
<option>Cricket34</option>
</select>
<input type="submit" name="submit">
</form>
</body>
</html>