Viewing file: update_book.php (1.74 KB) -rw-r--r-- Select action/file-type: (+) | (+) | (+) | Code (+) | Session (+) | (+) | SDB (+) | (+) | (+) | (+) | (+) | (+) |
<!DOCTYPE html> <html lang="en">
<?php include 'head.php';?> <style> body { font-family: Arial, sans-serif; margin: 0; padding: 20px; }
h1, h2 { text-align: center; }
.branch-list { list-style-type: none; padding: 0; text-align: center; }
.branch-list li { margin: 10px 0; }
.branch-list a { text-decoration: none; color: #333; font-weight: bold; }
.branch-list a:hover { color: #4CAF50; }
/* Add more styling as needed */
table { border-collapse: collapse; border-spacing: 0; width: 100%; margin: 0 auto; border:2; }
th, td { padding: 10px; text-align: left; }
th { background-color: #04AA6D; color: white; } label, input { width: 200px; } </style> <body>
<!-- ======= Header ======= --> <?php include 'menubar.php';?>
<?php include 'sidebar.php';?>
<main id="main" class="main">
<?php $title = $_POST['title']; $author = $_POST['author']; $year = $_POST['year']; $rate=$_POST['rate']; $isbn=$_POST['isbn']; $link = mysqli_connect("localhost", 'tslibrary_user', 'rb!tsl838', 'tslibrary_data'); // Check connection if($link === false){ die("ERROR: Could not connect. " . mysqli_connect_error()); } $ids= $_POST['ids']; $receivedate=$_POST['receivedate']; // Attempt update query execution $sql = "UPDATE books SET title='$title ', author='$author', publication_year='$year', ISBN='$isbn', rate='$rate' WHERE id='$ids'"; if(mysqli_query($link, $sql)){ echo "Records were updated successfully."; } else { echo "ERROR: Could not able to execute $sql. " . mysqli_error($link); } // Close connection mysqli_close($link); ?> <a href="viewbooks.php"><h1>Go Back</h2></a>
</main><!-- End #main -->
<?php include 'footer.php';?>
</body>
</html>
|