php checkbox question

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

    php checkbox question

    Hi

    I have a form with a list of checkboxes (http://mandatorymarketinginc.com/web/sample-01.png)

    These checkbox values were previously saved to a table called "comp-profile-03-specialties" and I got code working on the html form to to check and if specialty selected the checkbox is checked.

    On the html form checkboxes name is "specialties[]".

    However my problem comes in when I want to update the checkboxes to account for the possibilities if the a checkbox is de-selected or another checkbox is added.

    How would I go about doing this?

    Thanks.

    #2
    If the checkbox is checked, the value of it will be passed. Otherwise it won't.
    PHP Code:
    <?php
    if (isset($_POST['mycheckbox']))
    {
        echo 
    "checked!";
    }
    else
    {
    echo 
    "Not checked";
    }
    ?>
    Mobile chat, iphone chat, android chat, chat, rooms http://www.aiochat.com

    Comment


      #3
      Originally posted by katmac View Post
      Hi

      I have a form with a list of checkboxes (http://mandatorymarketinginc.com/web/sample-01.png)

      These checkbox values were previously saved to a table called "comp-profile-03-specialties" and I got code working on the html form to to check and if specialty selected the checkbox is checked.

      On the html form checkboxes name is "specialties[]".

      However my problem comes in when I want to update the checkboxes to account for the possibilities if the a checkbox is de-selected or another checkbox is added.

      How would I go about doing this?

      Thanks.
      It would be sooo much easier to help if you would post the code.
      <!DOCTYPE html PUBLIC "-//WAPFORUM.RS

      Comment


        #4
        Since i don't know where you are with your code, i can only suggest you that before the form you collect relevant values with mysql query and check it while parsing the form:

        PHP Code:
        echo '<option value="'.$var.'"'.($checked['value'] == $var ' selected="selected">' '>').$name.'</option>'."\n"
        This way saved and changed values are compared and changed or not with next submit...
        <!DOCTYPE html PUBLIC "-//WAPFORUM.RS

        Comment

        Working...
        X