Results 1 to 2 of 2
  1. #1
    Join Date
    Apr 2005
    Posts
    203

    Arrow Unanswered: How to insert checkbox values to mysql using php

    Hi all i got a form with a few checkbox on it. User select a few of checkboxes and and press a button to write their values to db. But i do not know how to write it to mysql db. I be happy if an expert help me with that.Thanks

    Note:Assuming the table has one columns which is for id value
    code for check box form

    Code:
    <form action="./write.php" method=post >
    
    <input type="checkbox" name="id" value="1"
    <input type="checkbox" name="id" value="2"
    <input type="checkbox" name="id" value="3"
    
    <input type="submit" value="Add this/these Songs to my PlayList" name="B1">

  2. #2
    Join Date
    Jan 2006
    Posts
    1

    Thumbs up

    HTML Form

    HTML Code:
    <form action="forum_dbforums_checkbox.php" method=post >
    
    <input type="checkbox" name="id[]" value="1">
    <input type="checkbox" name="id[]" value="2">
    <input type="checkbox" name="id[]" value="3">
    
    <input type="submit" value="Add this/these Songs to my PlayList" name="B1">
    Example Code [ write.php ]

    PHP Code:
    <?php

         
    while(list($key$value) = each($_POST['id'])) {
           echo 
    $key ' - ' $value;
         }

    ?>

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •