dimanche 4 décembre 2016

PHP: Display Column Names as Checkboxes, display as checked if column value is 1

I have the following table:

ID | Monday | Tuesday | Wednesday | Thursday | Friday
25 | 1      |  0      |   0       |  1       | 1

(this doesn't format right, imagine a table with zeros if a day is unchecked and ones if a day is checked)

And I want it on my html page to display like this:

Monday (checked checkbox)
Tuesday (unchecked checkbox)
Wednesday (unchecked checkbox)

and so on.

So far I have this PHP code, but it only gives me unchecked checkboxes without the day caption:

<?php    
$firstrow = false;
    while ($row = mysqli_fetch_assoc($res_skill)){
    if (!$firstrow) {
    foreach ($row as $column => $value) {
    echo "<input type='checkbox' name='data[]' value='". $column . "' /><br>"; 
    }
    $firstrow = true;
    }
    }
?>

What can I do?




Aucun commentaire:

Enregistrer un commentaire