Professional Documents
Culture Documents
Last Code Info Bryan
Last Code Info Bryan
Last Code Info Bryan
MySql
<?php
$servername = "localhost";
$username = "root"; // Your MySQL username
$password = ""; // Your MySQL password
$dbname = "student_db";
if ($conn->connect_error) {
die("Connection failed: " . $conn->connect_error);
}
?>
<?php
require_once 'config.php';
function getAllStudents() {
global $conn;
$sql = "SELECT * FROM students";
$result = $conn->query($sql);
return $result;
}
function getStudentById($id) {
global $conn;
$sql = "SELECT * FROM students WHERE id=$id";
$result = $conn->query($sql);
return $result->fetch_assoc();
}
function deleteStudent($id) {
global $conn;
$sql = "DELETE FROM students WHERE id=$id";
return $conn->query($sql);
}
?>
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Student Card</title>
<style>
body {
font-family: Arial, sans-serif;
background-color: #f5f5f5;
padding: 20px;
}
h1 {
color: #28b463;
margin-bottom: 30px;
}
form {
background-color: #fff;
padding: 20px;
border-radius: 4px;
box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}
label {
display: inline-block;
width: 150px;
text-align: right;
margin-right: 10px;
font-weight: bold;
color: #333;
}
input[type="text"] {
width: 300px;
padding: 5px;
border: 1px solid #ccc;
border-radius: 4px;
font-size: 16px;
line-height: 1.5;
color: #333;
}
input[type="submit"] {
background-color: #28b463;
color: #fff;
border: none;
padding: 10px 20px;
border-radius: 4px;
cursor: pointer;
font-size: 16px;
}
input[type="submit"]:hover {
background-color: #1a8c50;
}
</style>
</head>
<body>
<h1>Student Card</h1>
<form action="<?php echo htmlspecialchars($_SERVER["PHP_SELF"]); ?>"
method="post">
<label for="first_name">First Name:</label>
<input type="text" id="first_name" name="first_name" required><br>
<label for="last_name">Last Name:</label>
<input type="text" id="last_name" name="last_name" required><br>
<label for="student_id">Student ID:</label>
<input type="text" id="student_id" name="student_id" required><br>
<label for="course">Course:</label>
<input type="text" id="course" name="course" required><br>
<label for="semester">Semester:</label>
<input type="text" id="semester" name="semester" required><br>
<input type="submit" value="Add Student">
</form>
</body>
</html>