mirror of
https://github.com/Hizenberg469/BPIT-ATTENDANCE.git
synced 2026-04-20 02:02:25 +03:00
initial commit
This commit is contained in:
42
nakul/teacher_dash/get_students.php
Normal file
42
nakul/teacher_dash/get_students.php
Normal file
@@ -0,0 +1,42 @@
|
||||
<?php
|
||||
$servername = "localhost";
|
||||
$username = "usr";
|
||||
$password = "admin@1224";
|
||||
$dbname = "main_bpitattendance_db";
|
||||
|
||||
$conn = new mysqli($servername, $username, $password, $dbname);
|
||||
|
||||
if ($conn->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 "<table><tr><th>Student Name</th><th>Date of Birth</th><th>Batch Year</th></tr>";
|
||||
while($row = $result->fetch_assoc()) {
|
||||
echo "<tr><td>" . $row["stud_first_name"] . " " . $row["stud_last_name"] . "</td><td>" . $row["date_of_birth"] . "</td><td>" . $row["batch_year"] . "</td></tr>";
|
||||
}
|
||||
echo "</table>";
|
||||
} else {
|
||||
$row = $result->fetch_assoc();
|
||||
echo "<table><tr><th>Student Name</th><th>Date of Birth</th><th>Batch Year</th></tr>";
|
||||
echo "<tr><td>" . $row["stud_first_name"] . " " . $row["stud_last_name"] . "</td><td>" . $row["date_of_birth"] . "</td><td>" . $row["batch_year"] . "</td></tr>";
|
||||
echo "</table>";
|
||||
}
|
||||
} else {
|
||||
echo "0 results";
|
||||
}
|
||||
|
||||
$conn->close();
|
||||
?>
|
||||
Reference in New Issue
Block a user