connect_error) {
die("Connection failed: " . $conn->connect_error);
}
$searchType = $_GET['search_type'];
$searchText = $_GET['search_text'];
if ($searchType === "course") {
$sql = "SELECT stud_first_name, stud_last_name, date_of_birth, batch_year FROM student_record";
} else {
$sql = "SELECT stud_first_name, stud_last_name, date_of_birth, batch_year FROM student_record WHERE enrollment_no = '$searchText'";
}
$result = $conn->query($sql);
if ($result->num_rows > 0) {
if ($searchType === "course") {
echo "
| Student Name | Date of Birth | Batch Year |
";
while($row = $result->fetch_assoc()) {
echo "| " . $row["stud_first_name"] . " " . $row["stud_last_name"] . " | " . $row["date_of_birth"] . " | " . $row["batch_year"] . " |
";
}
echo "
";
} else {
$row = $result->fetch_assoc();
echo "| Student Name | Date of Birth | Batch Year |
";
echo "| " . $row["stud_first_name"] . " " . $row["stud_last_name"] . " | " . $row["date_of_birth"] . " | " . $row["batch_year"] . " |
";
echo "
";
}
} else {
echo "0 results";
}
$conn->close();
?>