How can PHP be used to create a web application for managing office availability?
To create a web application for managing office availability using PHP, you can start by designing a database to store office availability information. Then, create PHP scripts to interact with the database to add, update, and retrieve office availability data. Finally, build a user interface using HTML and CSS to allow users to view and manage office availability.
<?php
// Connect to the database
$servername = "localhost";
$username = "username";
$password = "password";
$dbname = "office_availability";
$conn = new mysqli($servername, $username, $password, $dbname);
// Check connection
if ($conn->connect_error) {
die("Connection failed: " . $conn->connect_error);
}
// Query to retrieve office availability data
$sql = "SELECT * FROM office_availability";
$result = $conn->query($sql);
// Display office availability data
if ($result->num_rows > 0) {
while($row = $result->fetch_assoc()) {
echo "Office: " . $row["office_name"]. " - Availability: " . $row["availability"]. "<br>";
}
} else {
echo "0 results";
}
$conn->close();
?>