I have been trying to populate a list of checkboxes which values and names are retrieved from MySQL as well. I believe I need to match two iD's together to be able to mark it as checked but I am not sure at the moment.
$boardsiD = $pClass->checkedBoards();
foreach($pClass->retrieveBoards() as $data)
{
$boardiD = $data['boardiD'];
$boardName = $data['boardName'];
if($boardiD == $boardsiD) ------------------ 1 ---------------------
{
$checked = 'checked="1"';
}
echo '
<li><input '.$checked.' type="checkbox" value="'.$boardiD.'">'.$boardName.'</li>
';
}
Where the dashes with the number one in the middle is, I am there checking if the board id's are the same and if so then the checked="1"
is applied. But it does not seem to be working.
The following is the output for the $boardsiD; These are the checkboxes that have been checekd in the database; saved the ids which is what I am trying to match against the $boardiD = $data['boardiD']
which is the whole list of id's(about 30 id's).
Array (
[0] => Array
([board_iD] => 106468047379795203)
[1] => Array
([board_iD] => 286119451265381250)
[2] => Array
([board_iD] => 136234026166934321)
[3] => Array
([board_iD] => 468022654964640361)
[4] => Array
([board_iD] => 409757334785529893)
[5] => Array
([board_iD] => 409757334785575605)
[6] => Array
([board_iD] => 490681390589888313)
)
I'm not sure if I can use preg_match for this or if I even should, I tried but it did not work very well, any ideas why the following does not work?