Jump to content

[SOLVED] Checkbox insert & retrieve from Database


aeafisme23

Recommended Posts

So i have created a form that easily adds/edits/deletes to a database except for the fact i cant update any of my checkboxes to the databases, only my input fields get updated. I just want the selected input to just update in the database under its field name/value to either be yes or no is sufficient enough. I'll give you my code and then a few of what i was thinking might be the problem, really interested in understanding this :)

    // this input addresses updates to database but the typeii checkbox does not updated and leaves the db blank

<tr valign="baseline">
      <td align="right" nowrap><div align="left">Address:</div></td>
      <td><input type="text" name="address" value="<?php echo $address ?>" size="32"></td>
      <td> </td>
      <td align="right" nowrap><div align="left">City:</div></td>
      <td><input type="text" name="city" value="<?php echo $city ?>" size="32"></td>
    </tr>
<td colspan="2" align="right" nowrap>
        
        <div align="left">
          <input <?php if (!(strcmp("yes","no"))) {echo "checked=\"checked\"";} ?> type="checkbox" name="typeii" value="<?php echo $typeii ?>" id="checkbox2">
      Type II (Conventional Anodize)</div></td>

 

Should i be more concerned with how each checkbox has its own id of checkbox(1,2,4,5,etc...) ex) id="checkbox2" ? and do a php echo of the vlue of checkbox2 and not my own determined name for it as typeii?

<input type="checkbox" name="typeii" value="<?php echo $typeii ?>" id="checkbox2">

 

if ($typeii != NULL) {

$typeii = "YES";

}

else {

$typeii = "NO";

}?>

 

and then i made input box <input type="checkbox" name="typeii" value="<?php echo $typeii ?>"> and it works, i guess i just needed to go at it harder. Thought i would at least give the community a solved so someone can benefit besides me.

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.