Viewing file: book_update_form.php (3.43 KB) -rw-r--r-- Select action/file-type: (+) | (+) | (+) | Code (+) | Session (+) | (+) | SDB (+) | (+) | (+) | (+) | (+) | (+) |
<!DOCTYPE html> <html lang="en">
<?php include 'head.php';?> <style> table { border-collapse: collapse; width: 100%; margin-top: 20px; }
table, th, td { border: 1px solid #ddd; }
th, td { padding: 8px; text-align: left; }
th { background-color: #f2f2f2; font-weight: bold; } </style> <body>
<!-- ======= Header ======= --> <?php include 'menubar.php';?>
<?php include 'sidebar.php';?>
<main id="main" class="main">
<meta charset="UTF-8"> <meta name="viewport" content="width=device-width, initial-scale=1.0"> <title>Add Book</title> <!-- Include Bootstrap CSS (you'll need to specify the correct path to your CSS file) --> <link rel="stylesheet" href="path/to/bootstrap.css"> </head> <body> <?php $var = @$_GET['q'];
$link = mysqli_connect("localhost", "tslibrary_user", "rb!tsl838", "tslibrary_data"); // Check connection if($link === false){ die("ERROR: Could not connect. " . mysqli_connect_error()); } $var = @$_GET['ID'];
// Attempt select query execution $sql = "SELECT * FROM books where ID='$var'"; if($result = mysqli_query($link, $sql)){ if(mysqli_num_rows($result) > 0){
while($row = mysqli_fetch_array($result)){ $title=$row['title']; $author=$row['author']; $publication_year=$row['publication_year']; $ISBN=$row['ISBN']; $rate=$row['rate']; } // Free result set mysqli_free_result($result); } else{ echo "Not Available any ID"; exit; } } else{ echo "ERROR: Could not able to execute $sql. " . mysqli_error($link); } // Close connection mysqli_close($link); ?> <div class="container"> <h1>Add Book</h1> <form action="update_book.php" method="post"> <div class="mb-3"> <label for="title" class="form-label">Title:</label> <input type="text" name="ids" class="form-control" value='<?php echo $var ?>' required> </div> <div class="mb-3"> <label for="title" class="form-label">Title:</label> <input type="text" name="title" class="form-control" value='<?php echo $title ?>' required> </div> <div class="mb-3"> <label for="author" class="form-label">Author:</label> <input type="text" name="author" class="form-control" value='<?php echo $author ?>' required> </div> <div class="mb-3"> <label for="year" class="form-label">Publication Year:</label> <input type="number" name="year" class="form-control" value='<?php echo $publication_year ?>'> </div> <div class="mb-3"> <label for="isbn" class="form-label">RATE:</label> <input type="text" name="rate" class="form-control" value='<?php echo $rate ?>' required> </div> <div class="mb-3"> <label for="isbn" class="form-label">ISBN:</label> <input type="text" name="isbn" class="form-control" value='<?php echo $ISBN ?>' required> </div> <button type="submit" class="btn btn-primary">Update Book</button> </form> </div>
<!-- Include Bootstrap JS and jQuery (if needed) at the end of your HTML, after the form --> <!-- This ensures that Bootstrap JavaScript features work correctly --> <script src="path/to/bootstrap.js"></script>
</main><!-- End #main -->
<?php include 'footer.php';?>
</body>
</html>
|