php - Looping through an array and check if checkbox is set -
I have a dynamically generated table on the page (based on the result of a query) I now check with the entry and checkbox I pass the box names in an array. The array is like a value like 10, 25, 26 ... in this value (checkbox-name) field with "Entry_ID" as well as Field-Defighter on other databases.
What I would like to do now is to check whether the checkbox is "on" on the dynamised generating table and update a field in the row with respect to "1" (review_done).
My code looks like ATM: (and does not work)
if (isset $ _POST ['retain'])) {$ lines = $ _SESSION ["Countro"]; $ Chkb_names = $ _SESSION ["arr_chkb_names"]; // print_r ($ chkb_names); ($ C = 0; $ c & lt; $ rows; $ c ++) {If isset ($ _ POST ($ chkb_names [$ c])) & amp; $ _POST ($ chkb_names [$ c] == 1)) {$ Sql = 'UPDATE testDB SET review_done =? WHERE entry_id =? '; $ Result = $ db- & gt; Ready ($ sql); $ Result-> Bind_param ('ii', 1, $ chkb_names [$ c]); $ Result-> Executed (); }}} Any help will be good !!! THX
You are using $ _ POST () which is incorrect $ _ POST is an array This should work
if (isset ($ _ POST ['maintainget'])) { $ Rows = $ _SESSION ["countRows"]; $ Chkb_names = $ _SESSION ["arr_chkb_names"]; // print_r ($ chkb_names); ($ C = 0; $ c & lt; $ rows; $ c ++) {If (isset ($ _ POST [$ chkb_names [$ c]]) {$ sql = 'UPDATE testDB SET review_done =? WHERE entry_ID = ? '; $ Result = $ db- & gt; ready ($ sql); $ result- & gt; bind_param (' ii ', $ review = 1, $ chkb_names [$ c]); $ result- & gt; executed Do ();}}}
Comments
Post a Comment