Search
 
SCRIPT & CODE EXAMPLE
 

PHP

multiple selected checkbox values in database

<?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 :: Class "AppHttpControllersAdminController" not found in laravel 8 
Php :: arrow function in php 
Php :: Disable wordpress editor - gutenberg on Post type post 
Php :: php force array keys trim 
Php :: find substring in string php 
Php :: Displaying the category name of a custom post type 
Php :: PHP sqrt() Function 
Php :: get day by date in php 
Php :: php convert to string 
Php :: php date set utc 
Php :: get deleted value laravel 
Php :: php pdo postegresql connection 
Php :: hash password laravel 
Php :: laravel guest blade 
Php :: laravel eloquent get all 
Php :: how to stop laravel server 
Php :: laravel order by numbers 
Php :: 419 page expired laravel 
Php :: html special characters php 
Php :: use resource in laravel 8 
Php :: how to fetch all column values php 
Php :: php realpath 
Php :: php strict mode 
Php :: Laravel Retrieve All Session Data 
Php :: php mail 
Php :: php unserialize array 
Php :: eloquent where parentheses 
Php :: how can set defult value for yield in laravel 
Php :: laravel with callback 
Php :: if condition in php 
ADD CONTENT
Topic
Content
Source link
Name
1+5 =