INSERT DIFFERENT TYPE MULTIPLE VALUES SELECTED IN CHECKBOX IN DATABASE

Geethu gopal

Total Post:1

Points:7
Posted by  Geethu gopal
MYSQL 
PHP
 892  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:40

    Points:288
    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 Aug-27-2015 05:20:05 AM

Answer

NEWSLETTER

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