INSERT DIFFERENT TYPE MULTIPLE VALUES SELECTED IN CHECKBOX IN DATABASE

Geethu gopal

Total Post:1

Points:7
Posted by  Geethu gopal
MYSQL 
PHP
 1089  View(s)
Ratings:
Rate this:
How to insert different type multiple values selected in checkbox in database ,
<?php
$checkbox1 = $_POST['batch']; 
$checkbox2 = $_POST['particular_name']; 
if(@isset($_REQUEST["sub"]))
{
     for ($i=0; $i<sizeof($checkbox1);$i++) {
     for ($j=0; $j<sizeof($checkbox2);$j++) {
    $query = "INSERT INTO table(`batch`,`particular_name`) values('".$checkboxi[$i]."','".$checkbox2[$j]."')";
    mysql_query($query) or die(mysql_error());
    }
    ?>
its not workin pls help me

  1. Sunil Singh

    Post:45

    Points:323
    Re: insert different type multiple values selected in checkbox in database

    try this code

    <?php
    
    $checkbox1=$_POST['batch'];
    $checkbox2=$_POST['particular_name'];
    if(@isset($_REQUEST["sub"]))
    {
    if(is_array($checkbox1)&&is_array($checkbox2)){
     foreach($checkbox1 as $val)
     {

      foreach($checkbox2 as $Value)
      {
         $query = "INSERT INTO table(`batch`,`particular_name`) VALUES('".$val."','".$Value."')";
          mysql_query($query) or die(mysql_error());
      }
     }

    }
    }
    ?>

      Modified On Apr-10-2018 02:29:18 AM

Answer

NEWSLETTER

Enter your email address here always to be updated. We promise not to spam!