In normal dropdown, user can select only one option in the drop down menu. Both Check box and multiple drop down box works same as each other. The reason for using multiple drop down box, instead of using check box is check box will take more space for options whereas dropdown box takes less space for any number of options.
Create database table with two fields (id and name).
[code type=sql]
CREATE TABLE `freeze`.`tb` (
`id` INT( 3 ) NOT NULL AUTO_INCREMENT ,
`name` VARCHAR( 50 ) NOT NULL ,
PRIMARY KEY ( `id` )
) ENGINE = INNODB;
[/code]
Here is the php code to insert more than one values into mysql table.
Give <select> html attribute name in array, that array value is imploded (i.e seperated) with (,) and imploded value is stored in $choice1
[code type=php]
<html>
<body>
<?php
if(isset($_POST[‘submit’]))
{
$query=mysql_connect(‘localhost’,’root’,”);
mysql_select_db(“freeze”,$query);
$choice=mysql_real_escape_string($_POST[‘game’]);
$choice1=implode(‘,’,$choice);
mysql_query(“insert into tb values(”,’$choice1′)”);
}
?>
<form method=”post” action=”index.php”>
Select your favourite game:<br/>
<select name=”game[]” multiple=”multiple”>
<option>Football</option>
<option>Volleyball</option>
<option>Badminton</option>
<option>Cricket</option>
</select>
<input type=”submit” name=”submit”>
</form>
</body>
</html>
[/code]
Could you help me for the following
How To Insert Multiple Values Using Check Box in PHP. The data which is checked should properly store in mysql db
Thanks in advance
check this article, if you have any other article or tutorial please ask us
http://freezecoders.com/2012/10/how-to-insert-data-using-check-box-in-php.html
This example is really very helpful thanks….
Could you help me for the following
How To Insert Multiple Values Using Single Text Box in PHP then move to multiple row data in MYSQL
Thanks in advance
nice work man, am very grateful for your help
How To: Insert Multiple Values with checkbox Using Dropdown List Box in PHP