<?php
if(isset($_POST['search']))
{
$department = $_POST['department'];
$class = $_POST['class'];
$i = 1;
$sql = "SELECT `student_id` , `name`, `htno`, `department`, `class` , `image_name` FROM student_detail where department=$department && class=$class";
$query = mysqli_query($conn, $sql);
if (!$query) {
die ('SQL Error: ' . mysqli_error($conn));
}
while ($row = mysqli_fetch_array($query)) {?>
<tr>
<td><?php echo $i++; ?></td>
<td><?php echo $row['name']; ?></td>
<td><?php echo $row['htno']; ?></td>
<td><?php echo $row['department']; ?></td>
<td><?php echo $row['class']; ?></td>
<td>
<button data-toggle="modal" data-target="#view-modal" data-id="<?php echo $row['student_id']; ?>" id="getStudent" class="btn cur-p btn-info"><i class="glyphicon glyphicon-eye-open"></i> View</button>
<a href="<?php echo BASE_URL; ?>/controller/delete.php?student_id=<?php echo $row['student_id']; ?>" class="btn cur-p btn-danger" onClick="return confirm('Are you sure you want to delete?')">Delete</a></button>
</td>
</tr>
<?php }
if ($result === false) {
echo "No Data Found";
}
}
?>
Getting error while using this code
SQL Error: You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near 'A' at line 1
What is wrong?