Professional Documents
Culture Documents
Aim:
Algorithm:
<?php
// Database configuration
if ($mysqli->connect_error) {
// Create operation
if (isset($_POST['create'])) {
$name = $_POST['name'];
$email = $_POST['email'];
if ($stmt->execute()) {
} else {
$stmt->close();
$users = array();
if ($result->num_rows > 0) {
$users[] = $row;
}
// Update operation
if (isset($_POST['update'])) {
$id = $_POST['id'];
$newName = $_POST['new_name'];
$newEmail = $_POST['new_email'];
if ($stmt->execute()) {
} else {
$stmt->close();
}
// Delete operation
if (isset($_POST['delete'])) {
$id = $_POST['id'];
$stmt->bind_param("i", $id);
if ($stmt->execute()) {
} else {
$stmt->close();
$mysqli->close();
?>
<!DOCTYPE html>
<html>
<head>
</head>
<body>
<h2>Create Record</h2>
<form method="post">
</form>
<h2>Read Records</h2>
<table border="1">
<tr>
<th>ID</th>
<th>Name</th>
<th>Email</th>
<th>Actions</th>
</tr>
<tr>
<td>
<form method="post">
</form>
</td>
</tr>
</table>
</body>
</html>
Output
Result: