Answers for "add multiple value in option select"

1

how to insert multiple selected

<?php
// Make a MySQL Connection
mysql_connect("HOST_NAME", "USERNAME", "PASSWORD") or die(mysql_error());
mysql_select_db("DB_NAME") or die(mysql_error());
$checkBox = implode(',', $_POST['Colors']);
if(isset($_POST['submit']))
{       
    $query="INSERT INTO clr_tbl (colors) VALUES ('" . $checkBox . "')";     

    mysql_query($query) or die (mysql_error() );

    echo "Complete";

}

?>

<html>
<body>
<form method="post" action="">
  <input type="checkbox" name="Colors[]" value="Red">Red<br>
  <input type="checkbox" name="Colors[]" value="Blue">Blue<br>
  <input type="checkbox" name="Colors[]" value="Pink">Pink<br>
  <input type="submit" name="submit" value="submit">
</form>
</body>
</html>
Posted by: Guest on March-25-2022
7

how to choose multiple option from select option

<!-- JUST ADD multiple ATTRIBUTE WITHIN select ATTRIBUTE -->
Cars:<br>
<select name="car" multiple>
    <option value="Volvo">Volvo</option>
    <option value="Thar">Thar</option>
    <option value="Audi">Audi</option>
</select>
Posted by: Guest on August-23-2020

Code answers related to "add multiple value in option select"

Browse Popular Code Answers by Language