Click here to Skip to main content
15,884,176 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
here i am having a form like this

XML
<?php
          $sql="select * from tb_transport";
        $query=mysql_query($sql);
  while($row=mysql_fetch_array($query))
     {
     ?>

        <input type="checkbox" name="transport[]" value="<?php echo        $row["id"];?>"><?php echo $row["name"];?><input  type="text" name="dsec[]" value="">Daily<br>
<?php } ?>
<input type="submit" name="submit" value="submit">
</form>


i am having multiple checkboxes that are coming from database and i have given a field with every checkbox...now suppose 10 checkboxes are coming from database..now i want to insert values in database only of those checkboxes which are checked along with their textbox values..here is my php script


PHP
if(isset($_POST["submit"]))
{
 for($i=0;$i<count($_POST["transport"]); $i++)
      {
          $transport=$_POST["transport"][$i];
          $dsec=$_POST["dsec"][$i];

        mysql_query("insert into transport_two set transport_id='$transport',name='$dsec'");

      }
}

?>


when i click on submit button the checkbox values are getting inserted right but the textbox values are not getting inserted... can anyone help me with the code ??
Posted

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900