0

I am trying to get the values of selected check boxes within a form however I need to store an array within the value tag which holds an ID and the Day.

Something like so:

echo '<label><input type="checkbox" name="check_list[ind]" id="'.$ind['ID'].'" value="'.$valueArr[$ind['ID']]['Fri'].'">Friday</label>';

echo '<label><input type="checkbox" name="check_list[grp]" id="'.$ind['ID'].'" value="'.$valueArr[$ind['ID']]['Sat'].'">Sat</label>';


if (isset($_POST['check_list'])){
    $indchks = $_POST['check_list']['ind'];
    $grpchks = $_POST['check_list']['grp'];

    $G = count($grpchks);
    $N = count($indchks);

    for($i = 0; $i < $N; $i++){
        //Need to somehow delve into the value array?
        //insertIndBooking($talent_id, $id, $day);
    }

These values will later have to be read and posted to a DB. My problem being, I am not so certain what I am doing is correct or how I am going to read this array.

Any and all help is gratefully received

Kind Regards,

RiggsFolly
  • 93,638
  • 21
  • 103
  • 149
Sm1ley
  • 21
  • 3
  • Add [error reporting](http://stackoverflow.com/questions/845021/how-to-get-useful-error-messages-in-php/845025#845025) to the top of your file(s) _while testing_ right after your opening PHP tag for example ` – RiggsFolly May 26 '16 at 08:21
  • Have you looked at what gets placed on the pace using `view page source` in your browser – RiggsFolly May 26 '16 at 08:21
  • If you are not sure what your $_POST array looks like add a `print_r($_POST);` to your code and you will see it shown to you – RiggsFolly May 26 '16 at 08:23
  • I am getting `Notice: Undefined index: grp Notice: Uninitialized string offset: 0 ` as well as the many `Notice: Undefined variable: valueArr ` ... – Sm1ley May 26 '16 at 08:28
  • Well then look at each error, **each gives you a line number** and fix whatever is wrong – RiggsFolly May 26 '16 at 08:32
  • I am getting Array ( [check_list] => Array ( [ind] => ) therefore those arrays in the values are not quite what they should. – Sm1ley May 26 '16 at 08:33
  • Count the opening and closing brackets on this `$valueArr[$ind['ID']]['Fri']` they do not match – RiggsFolly May 26 '16 at 08:34
  • So your first comment on the $ValueArr being wrong was spot on. – Sm1ley May 26 '16 at 08:34

0 Answers0