Jump to content

Form Checkboxes - inserting into a database


rich11

Recommended Posts

Hello,

 

I have a survey that i am doing, and one of the questions is pick your top two questions out of  six answers.  When I submit the form how do I know what check boxes they click and how do I know if they clicked three instead of two??

 

Thank you... here is my code for the question

 

    <tr>

        <td width="33%"><font face="Arial">

        <input type="checkbox" name="C6" value="ON"><font size="2"> Hospital

        newsletter</font></font></td>

      </tr>

      <tr>

        <td width="33%"><font face="Arial">

        <input type="checkbox" name="C7" value="ON"><font size="2"> Posters/Tent

        Cards</font></font></td>

      </tr>

      <tr>

        <td width="33%"><font face="Arial">

        <input type="checkbox" name="C8" value="ON"><font size="2"> Awareness

        Website</font></font></td>

      </tr>

      <tr>

        <td width="33%"><font face="Arial">

        <input type="checkbox" name="C9" value="ON"><font size="2"> Energy

        Newsletter</font></font></td>

      </tr>

      <tr>

        <td width="33%"><font face="Arial">

        <input type="checkbox" name="C10" value="ON"><font size="2"> Displays</font></font></td>

      </tr>

      <tr>

        <td width="33%"><font face="Arial">

        <input type="checkbox" name="C11" value="ON"><font size="2"> Intranet</font></font></td>

      </tr>

do something like:

 

if(isset($_POST['C6'])) {
  $checboxes_set + 1;
}

if(isset($_POST['C7'])) {
  $checboxes_set + 1;
}

if(isset($_POST['C8'])) {
  $checboxes_set + 1;
}

if(isset($_POST['C9'])) {
  $checboxes_set + 1;
}

if(isset($_POST['C10'])) {
  $checboxes_set + 1;
}

if(isset($_POST['C11'])) {
  $checboxes_set + 1;
}

echo "ammount of echboxes set: $cechkboxes_set";

I changed the code a bit.. but mostly the code you gave me... but it won't print anything out... the $total variable won't display.  did I mess upo the code??

 

Rich

 

if(isset($_POST["C1"])) {

  $total + 1;

}

 

if(isset($_POST["C2"])) {

$total + 1;

}

 

if(isset($_POST["C3"])) {

$total + 1;

}

 

 

if(isset($_POST["C4"])) {

$total + 1;

}

 

 

echo "<br>"; echo "<br>"; echo "<br>"; echo "<br>";

echo "$total";

Ok.....  maybe i asked the wrong question.

 

I want to take each text box that was checked, add each value of the textbox together in one string varaible seperated by a comma.  Once I have that string variable I am going to insert it into a database field.

 

Thx,

Rich

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.