enter image description herehello I know this sound stupid but I’m practicing how to code and use relational database using core php and mysql and the select query I made is showing the all the result from database from grade 7 and 8 it should show only grade 9 because the school year status is set to yes from that particular school year and I can’t see what I did wrong I’m pretty sure I’m doing it right already
$status = 'Yes';
$adviser_id = $_SESSION['user_id'];
$stmt = $mysqli->prepare("SELECT student_class.student_id, student_info.lrn_no, student_info.lastname, student_info.firstname, student_info.middlename, student_class.school_year,student_class.grade, student_class.section, student_class_info.action FROM student_class
INNER JOIN student_info ON student_class.student_id = student_info.student_id
INNER JOIN student_class_info ON student_class.student_id = student_class_info.student_id
INNER JOIN school_year ON student_class.school_year = school_year.sy_id
INNER JOIN users ON student_class.adviser_id = users.user_id WHERE school_year.status=? AND student_class.adviser_id = ? ");
//bind parameter
$stmt->bind_param("si", $status, $adviser_id);
//execute
$stmt->execute();
//bind variables to prepared statement +
$stmt->bind_result( $student,$lrn, $ln, $fn, $mn,$sy,$grade, $section, $action);
//fetch the data
while ($stmt->fetch()){
?>
<tr>
<td style="display:none;" class="student_id"><?php echo $student ?></td>
<td><?php echo $lrn ?></td>
<td style="text-transform:capitalize;"><?php echo $ln ?>, <?php echo $fn ?> <?php echo $mn ?></td>
<td class="d-flex justify-content-center">
<a href="viewstudentinfo.php?student=<?php echo $student ?>"><button class="btn btn-info info_btn" data-bs-toggle="modal" ><i class="bi bi-info-circle"></i> Info</button></a>     
<a href="form137.php?student=<?php echo $student ?>"><button class="btn btn-success" data-bs-toggle="modal" data-bs-target="#editModal" ><i class="bi bi-eye"></i> Form 137</button></a>     
<a href="record.php?student=<?php echo $student ?>¤t=<?php echo $grade?>&class=<?php echo $section?>&yearid=<?php echo $sy?>"><button class="btn btn-danger"><i class="bi bi-archive"></i> Record</button></a>
</td>
<?php if($action=='PROMOTED'){ ?>
<td class="text-center" style="color:green;"> <b><?php echo $action?></b></td>
<?php } elseif ($action=='RETAINED'){ ?>
<td class="text-center" style="color:red;"><b><?php echo $action ?><b></td>
<?php } else {?>
<td class="text-center"><b><?php echo $action ?><b></td>
<?php } ?>
</tr>
<?php
}
$stmt->close();