Hi, I am trying to create a attendance system which displays of student if it came or not, by date.
Thank you very much in advance
<?php
$t=time();
if(isset($_GET['submit']) && !empty($_GET['sdate']) && !empty($_GET['edate']) && ($_GET['edate'] > $_GET['sdate'])
&& ($_GET['sdate']<$t) && ($_GET['edate']<$t))
{
$sdat = $_GET['sdate'];
$edat= $_GET['edate'];
$sdate = strtotime($sdat);
$edate = strtotime($edat);
if(($sdate<$t) && ($edate<=$t) && ($edate >= $sdate))
{
$query_student = "
SELECT * from yaz_okulu_2023 JOIN yaz_okulu_2023_devamsizlik
WHERE yaz_okulu_2023.id = yaz_okulu_2023_devamsizlik.postId
";
$stu=$conn->query($query_student);
$rstu=$stu->fetchAll(PDO::FETCH_ASSOC);
echo "<table class='table table-striped table-hover reports-table'>";
echo "<thead>";
echo "<tr>";
echo "<th>kayıt no</th>";
echo "<th>adi soyadi</th>";
for($k=$sdate;$k<=$edate;$k=$k+86400)
{
$thisDate = date( 'd-m-Y', $k );
$weekday= date("l", $k );
$normalized_weekday = strtolower($weekday);
if(($normalized_weekday="saturday") && ($normalized_weekday="sunday"))
{
echo "<th>".$thisDate."</th>";
}
}
echo "<th></th>";
echo "<th></th>";;
echo "</tr>";
echo "</thead>";
echo "</tbody>";
for($i=0;$i<count($rstu);$i++)
{
$present=0;
$absent=0;
$totlec=0;
$perc=0;
echo"<tr><td><h6>".$rstu[$i]['postId']."</h6></td>";
echo "<td><h5>".$rstu[$i]['ogr_adi_soyadi']."</h5></td>";
$dsid=$rstu[$i]['postId'];
for($j=$sdate;$j<=$edate;$j=$j+86400)
{
$weekday= date("l", $j );
$currentDate = date('Y-m-d', $j);
$normalized_weekday = strtolower($weekday);
if(($normalized_weekday="saturday") && ($normalized_weekday="sunday"))
{
$sql = "SELECT * from yaz_okulu_2023 JOIN yaz_okulu_2023_devamsizlik
WHERE yaz_okulu_2023.id =$dsid AND yaz_okulu_2023_devamsizlik.geldi_tarihi=$j " ;
$stmt = $conn->prepare($sql);
$stmt->execute();
$result = $stmt->fetchAll(PDO::FETCH_ASSOC);
if(!empty($result)){
$totlec++;
if($result[0]['yaz_okulu_2023_devamsizlik.geldi_mi']==1)
{
$present++;
echo"<td><span class='text-success'>Yes</span></td>";
}
else
{
echo"<td><span class='text-danger'>No</span></td>";
$absent++;
}
}
}
}
echo"</tr>";
}
echo "</tbody>";
echo "</table>";
}else
{
print '<div class="alert alert-dismissible alert-danger">
<button type="button" class="close" data-dismiss="alert">×</button>
<strong>Sorry!</strong>Please enter correct date range.
</div>';
}
}else{
}
?>