<?php
$con=mysqli_connect("localhost","root","","User_db");
// Check connection
if (mysqli_connect_errno())
{
echo "Failed to connect to MySQL: " . mysqli_connect_error();
}
$result = mysqli_query($con,"SELECT * FROM Assessments");
echo "<table class='sortable' border='0' cellpadding='40'
cellspacing='0'>
<thead>
<tr>
<th>Title</th>
<th>Lecturer</th>
<th>Start</th>
<th>Due</th>
<th>Completed</th>
</tr>
</thead>";
while($row = mysqli_fetch_array($result))
{
echo "<tr>";
echo "<td>" . $row['Title'] . "</td>";
echo "<td>" . $row['Lecturer'] . "</td>";
echo "<td>" . $row['Start'] . "</td>";
echo "<td id='Due'>" . $row['Due'] . "</td>";
echo "<td>" ."<input type='checkbox' id='mycheckbox' name='Completed' value='Completed' />";
echo "</tr>";
}
echo "</table>";
mysqli_close($con);
?>
Hello guys I was wondering if the checkbox would get check when the date on $row['Due'] is reached for example 14/04/2013 is the date on Srow['Due']. The checkbox should automatically get the date and check the checkbox permanently.Checkbox Toggle
Checkbox Toggle
-
ExtremeGaming
- Posts: 205
- Joined: Mon Jul 09, 2012 11:13 pm
Re: Checkbox Toggle
You're going to need to use the php date function.
<?php
If($row['date'] == date(stuff)) {
// use the checked property of the checkbox
} else {
// use a normal checkbox
}
?><?php while(!$succeed = try()); ?>
Re: Checkbox Toggle
If it's the HTML bit you're unsure of, the following will check the box by default (use it alongside ExtremeGaming's suggestion):
This can be modified client-side to be a normal editable checkbox.
<input type="checkbox" name="travelMethod" value="bike" checked>I use a BikeAnd if you don't want the user to be able to un-check the box:
<input type="checkbox" name="travelMethod" value="bike" checked disabled>I use a BikeHowever, do not rely on the "disabled" part of the input.
This can be modified client-side to be a normal editable checkbox.