Search
 
SCRIPT & CODE EXAMPLE
 

PHP

how to insert multiple selected checkbox values in database in php

<?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>
Comment

PREVIOUS NEXT
Code Example
Php :: create if not exist laravel 
Php :: laravel update return updated row, laravel update return 
Php :: adding days in datetime php 
Php :: Command for single migration in larvel 
Php :: push collection php 
Php :: avg rating get in join in laravel 8 
Php :: Merge Two Collection ( Laravel ) 
Php :: php Convert String containing commas to array 
Php :: laravel auth 6 
Php :: php laravel config 
Php :: php artisan test 
Php :: target class admin homecontroller does not exist laravel 8 
Php :: custom laravel auth 
Php :: drupal set message 
Php :: env value return null laravel 
Php :: php strtotime plus 1 day 
Php :: php query pdo 
Php :: define site url wordpress 
Php :: Fatal error: Composer detected issues in your platform: Your Composer dependencies require a PHP version "= 8.1.0". You are running 8.0.8. in /Applications/MAMP/htdocs/schools/vendor/composer/platform_check.php on line 24 
Php :: return view with variable laravel 
Php :: laravel enum validation 
Php :: laravel return view in web.php 
Php :: codeigniter abort 404 
Php :: softdeletes laravel 
Php :: array of dates laravel 
Php :: laravel insert array 
Php :: woocommerce phone number not required 
Php :: laravel migration alter column unique 
Php :: str_shuffle in php 
Php :: concatener 2 variables php 
ADD CONTENT
Topic
Content
Source link
Name
1+4 =