Jump to content

Checkboxes help


tjg73

Recommended Posts

Perhaps this is an HTML question but since my question relates to MySQL I am thinking it is more PHP.  I really need help figuring out how change the status of a checkbox from not checked to checked based on its value in the database.  In the database the checkbox column says "YES"  (that it has been checked)  When the page is visited at a later date, I need to pull that value from the database and have that checkbox now CHECKED.  Did this make sense?  Can anyone help?

 

thanks

 

Link to comment
Share on other sites

Try this:

========

 

$checked = ($database_value == "YES") ? "checked" : "";

 

Use this $checked variable in the checkbox html tag as like below:

<input type='checkbox'  name='something' value='somethingsomething' $checked>

 

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.