im trying to compare two dates
. I want the table
to be editable
if the start date
is greater than or equals to current date and end date
is less than or equals to current date
. Here's my scenario to explain it easily, I will set a specific dates
for encoding of grades so if the current date
is not in between
of the start
and end
date the table will not be editable
. Can someone help me find the cause of the problem? Is it my condition?
The data.
The code.
$sql1 = "SELECT * FROM encode";
$results = mysqli_query($con,$sql1);
while($rows = mysqli_fetch_array($results)){
$term = $rows['term'];
$enddate = $rows['enddate'];
$startdate = $rows['startdate'];
}
$today = date("Y-m-d");
if(mysqli_num_rows($results) == 0){
$output .= '<tr>
<td>'.$row['lastname'].'</td>
<td>'.$row['firstname'].'</td>
<td>'.$row['middlename'].'</td>
<td class="prelim" data-id1="'.$row['grade_id'].'" >'.$row['prelim_grade'].'</td>
<td class="midterm" data-id2="'.$row['grade_id'].'" >'.$row['midterm_grade'].'</td>
<td class="finals" data-id3="'.$row['grade_id'].'" >'.$row['finals_grade'].'</td>
<td class="final" data-id4="'.$row['grade_id'].'" >'.$row['final_grade'].'</td>
</tr>';
}
else{
$output .= '<tr>
<td>'.$row['lastname'].'</td>
<td>'.$row['firstname'].'</td>
<td>'.$row['middlename'].'</td>';
if($term == "Prelim" && $enddate <= $today && $startdate >= $today){
$output .= '<td class="prelim" data-id1="'.$row['grade_id'].'" contenteditable>'.$row['prelim_grade'].'</td>';
}
else{
$output .= '<td class="prelim" data-id1="'.$row['grade_id'].'">'.$row['prelim_grade'].'</td>';
}
if($term == "Midterm" && $enddate <= $today && $startdate >= $today){
$output .= '<td class="midterm" data-id2="'.$row['grade_id'].'" contenteditable>'.$row['midterm_grade'].'</td>';
}
else{
$output .= '<td class="midterm" data-id2="'.$row['grade_id'].'">'.$row['midterm_grade'].'</td>';
}
if($term == "Finals" && $enddate <= $today && $startdate >= $today){
$output .= '<td class="finals" data-id3="'.$row['grade_id'].'" contenteditable>'.$row['finals_grade'].'</td>';
}
else{
$output .= '<td class="finals" data-id3="'.$row['grade_id'].'">'.$row['finals_grade'].'</td>';
}
if($term == "Final Grade" && $enddate <= $today && $startdate >= $today){
$output .= ' <td class="final" data-id4="'.$row['grade_id'].'" contenteditable>'.$row['final_grade'].'</td>';
}
else{
$output .= ' <td class="final" data-id4="'.$row['grade_id'].'">'.$row['final_grade'].'</td>';
}
$output .=' </tr>';
}