mardi 1 juin 2021

Show checkbox checked in the table

I have a problem showing the selected check value in the table. Now I cannot follow my selected value to show the check values in each row in the table.

For example below coding,I have the selected values following are true,false,true,false,true,false, I need to show these values in the checkbox, so I make these value to become checked or uncheck, if value is true then will checked, else will uncheck:

<?php 
$myString = "true,false,true,false,true,false";
$myArray = explode(',', $myString);

foreach ($myArray as $k => $va) { 
$check_val = $va;
}
if($check_val == "true"){
    $tick = "checked";
}else{
    $tick = " ";
}
?>

This is my working online editor: https://paiza.io/projects/D-J1uBPeHJuL8jCOhToRQQ

I want the expected result like below the picture, the selected values can follow by true,false,true,false,true,falsein each row in the table:

output1

Hope someone can guide me on how to solve this problem. Thanks.




Aucun commentaire:

Enregistrer un commentaire