New Text Document
New Text Document
# Database Schema
Create a new database in MySQL called zoo_management and add the following tables:
# PHP Code
Create a new file called db.php and add the following code:
<?php
$servername = "localhost";
$username = "root";
$password = "";
$dbname = "zoo_management";
// Create connection
$conn = new mysqli($servername, $username, $password, $dbname);
// Check connection
if ($conn->connect_error) {
die("Connection failed: " . $conn->connect_error);
}
?>
Create a new file called index.php and add the following code:
<?php
include 'db.php';
// Display data
?>
<!DOCTYPE html>
<html>
<head>
<title>Zoo Management System</title>
<link rel="stylesheet" type="text/css" href="styles.css">
</head>
<body>
<h1>Zoo Management System</h1>
<h2>Animals</h2>
<table>
<tr>
<th>Animal ID</th>
<th>Name</th>
<th>Species</th>
<th>Age</th>
</tr>
<?php while($row = $animals->fetch_assoc()) { ?>
<tr>
<td><?php echo $row['animal_id']; ?></td>
<td><?php echo $row['name']; ?></td>
<td><?php echo $row['species']; ?></td>
<td><?php echo $row['age']; ?></td>
</tr>
<?php } ?>
</table>
<h2>Employees</h2>
<table>
<tr>
<th>Employee ID</th>
<th>Name</th>
<th>Position</th>
</tr>
<?php while($row = $employees->fetch_assoc()) { ?>
<tr>
<td><?php echo $row['employee_id']; ?></td>
<td><?php echo $row['name']; ?></td>
<td><?php echo $row['position']; ?></td>
</tr>
<?php } ?>
</table>
<h2>Visitors</h2>
<table>
<tr>
<th>Visitor ID</th>
<th>Name</th>
<th>Date Visited</th>
</tr>
<?php while($row = $visitors->fetch_assoc()) { ?>
<tr>
<td><?php echo $row['visitor_id']; ?></td>
<td><?php echo $row['name']; ?></td>
<td><?php echo $row['date_visited']; ?></td>
</tr>
<?php } ?>
</table>
</body>
</html>
# CSS Code
Create a new file called styles.css and add the following code:
body {
font-family: Arial, sans-serif;
}
table {
border-collapse: collapse;
width: 100%;
}
th, td {
border: 1px solid #ddd;
padding: 10px;
text-align: left;
}
th {
background-color: #f0f0f0;
}
This is a basic example to get you started. You can add more features, styles, and
functionality as needed.