PHP : Turn checked checkboxes into list of items for database table and check boxes based on values stored in database table on page load -
I am storing the contents in a database table. A table column is called attrbutes
and there is a list of values based on that checkbox (like: 1, 3, 5
).
You change the html: 1) 2) 3)
& lt; Input type = "checkbox" name = "attribute []" value = "1" & gt; Attr 1 & lt; Br> & Lt; Input type = "checkbox" name = "attribute []" value = "2" & gt; Attr 2 & lt; Br> & Lt; Input type = "checkbox" name = "attribute []" value = "3" & gt; Attr 3 & lt; Br> & Lt; Input type = "checkbox" name = "attribute []" value = "4" & gt; Attr 4 & lt; Br> & Lt; Input type = "checkbox" name = "attribute []" value = "5" & gt; Attr 5 & lt; Br>
$ checkered entry = $ _POST ['attribute']; If (counted ($ checked attree)), "At least one checkbox is selected";
$ checkboxList = implode (',', $ checkedAttr);
$ checked = explosion (',', $ yourQueryResultStringContainingTheCheckedList); & Lt; Input type = "checkbox" name = "attribute []" value = "1" & lt ?? Php if (in_array ('1', $ checked at)) 'checked = \ "checked \"'; ? & Gt; Entry 1 & lt; Br> ...
Comments
Post a Comment