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. I know that the input tag contains "checked" if you want the checkbox to be checked. but i need to insert an if condition into the input tag, that says if the $value is 1 then echo "checked". it is probably just a question of formatting the php inside the html inside the php correctly.
So far I have this PHP code, but it only gives me unchecked checkboxes without the day caption:
<html>
<?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;
}
}
?>
</html>
What can I do?
$columnisn't it? Then what is the problem?checkedattrubite forinputtag.