Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php include('server.php');
- //fetch the record to be updated
- if (isset($_GET['edit'])) {
- $id = $_GET['edit'];
- $edit_state = true;
- $rec = mysqli_query($db, "SELECT * FROM info WHERE id=$id");
- $record = mysqli_fetch_array($rec);
- $title = $record['title'];
- $author = $record['author'];
- $genre = $record['genre'];
- $isbn = $record['isbn'];
- $callnumber = $record['callnumber'];
- $bookin = $record['bookin'];
- $bookout = $record['bookout'];
- $id = $record['id'];
- }
- ?>
- <!doctype html>
- <html>
- <head>
- <TITLE>LIBRARY SYSTEM</TITLE>
- <link rel="stylesheet" type"text/css" href="style.css">
- </head>
- <body>
- <?php if (isset($_SESSION['msg'])): ?>
- <div class="msg">
- <?php
- echo $_SESSION['msg'];
- unset($_SESSION['msg']);
- ?>
- </div>
- <?php endif ?>
- <table>
- <thead>
- <tr>
- <th>Title</th>
- <th>Author</th>
- <th>Genre</th>
- <th>ISBN</th>
- <th>Call Number</th>
- <th>Book in</th>
- <th>Book out</th>
- <th colspan="2">ACTION</th>
- </tr>
- </thead>
- <tbody>
- <?php while ($row = mysqli_fetch_array($results)) { ?>
- <tr>
- <td><?php echo $row['title']; ?></td>
- <td><?php echo $row['author']; ?></td>
- <td><?php echo $row['genre']; ?></td>
- <td><?php echo $row['isbn']; ?></td>
- <td><?php echo $row['callnumber']; ?></td>
- <td><?php echo $row['bookin']; ?></td>
- <td><?php echo $row['bookout']; ?></td>
- <td>
- <a class="edit_btn" href="index.php?edit=<?php echo $row['id']; ?>">Edit</a>
- </td>
- <td>
- <a class="del_btn" href="server.php?del=<?php echo $row['id']; ?>">Delete</a>
- </td>
- </tr >
- <?php } ?>
- </tbody>
- </table>
- <form method="post" action="server.php">
- <input type="hidden" name="id" value="<?php echo $id; ?>">
- <div class="input-group">
- <label>Title</label>
- <input type="text" name="title" value="<?php echo $title; ?>">
- </div>
- <div class="input-group">
- <label>Author</label>
- <input type="text" name="author" value="<?php echo $author; ?>">
- </div>
- <div class="input-group">
- <label>Genre</label>
- <input type="text" name="genre" value="<?php echo $genre; ?>">
- </div>
- <div class="input-group">
- <label>ISBN</label>
- <input type="text" name="isbn" value="<?php echo $isbn; ?>">
- </div>
- <div class="input-group">
- <label>Call Number</label>
- <input type="text" name="callnumber" value="<?php echo $callnumber; ?>">
- </div>
- <div class="input-group">
- <label>Book in</label>
- <input type="text" name="bookin" value="<?php echo $bookin; ?>">
- </div>
- <div class="input-group">
- <label>Book out</label>
- <input type="text" name="bookout" value="<?php echo $bookout; ?>">
- </div>
- <div class="input-group">
- <?php if ($edit_state == false): ?>
- <button type="submit" name="save" class="btn">Save</button>
- <?php else: ?>
- <button type="submit" name="update" class="btn">Update</button>
- <?php endif ?>
- </div>
- </form>
- </body>
- </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement