0

I have a dinamycly generated table on my page (depending on a result from a query) with entrys and checkboxes. Now I pass the checkboxnames to an array. The array have then values like eg. 10, 25, 26 ... in it. This values (checkboxnames) are also field-identifyer on a second database with the field "entry_ID".

What I would like to do now is to check if a checkbox is "ON" on the dynamicly generated table and update a field in the depending row with "1" (review_done).

My code looks like so atm: (and does not work)

if (isset($_POST['maintget']))  
        {

        $rows = $_SESSION["countRows"];
        $chkb_names = $_SESSION["arr_chkb_names"];

        //print_r($chkb_names);

        for ($c = 0; $c<$rows; $c++)
            {

                if(isset($_POST($chkb_names[$c])) && $_POST($chkb_names[$c] == 1))
                {                       
                    $sql    = 'UPDATE testDB SET review_done=? WHERE entry_ID =?';
                    $result = $db->prepare( $sql );
                    $result->bind_param('ii', 1,$chkb_names[$c]);
                    $result->execute(); 
                }
            }
        }

Any help would be nice!!! THX

iridium
  • 5
  • 2

1 Answers1

0

you are using $_POST( ) which is wrong. $_POST is an array

this should work

 if (isset($_POST['maintget']))  
    {

    $rows = $_SESSION["countRows"];
    $chkb_names = $_SESSION["arr_chkb_names"];

    //print_r($chkb_names);

    for ($c = 0; $c<$rows; $c++)
        {

            if(isset($_POST[$chkb_names[$c]])
            {                       
                $sql    = 'UPDATE testDB SET review_done=? WHERE entry_ID =?';
                $result = $db->prepare( $sql );
                $result->bind_param('ii', $review=1,$chkb_names[$c]);
                $result->execute(); 
            }
        }
    }
iridium
  • 5
  • 2
anurupr
  • 2,294
  • 2
  • 20
  • 28
  • you need to start debugging properly to see where your errors . follow this http://stackoverflow.com/questions/18050071/php-parse-syntax-errors-and-how-to-solve-them – anurupr Feb 17 '14 at 10:16