Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- $hostname = "localhost";
- $dbname = "value";
- $username = "value";
- $password = "value";
- $conn = new MySQLi($hostname, $username, $password, $dbname) or die('Can not connect to database')
- ?>
- <html>
- <head>
- <title>Untitled Document</title>
- </head>
- <body>
- <?php
- if(isset($_POST['Submit'])){
- $pubdate = $_POST['updatepubdate'];
- $title = $_POST['updatetitle'];
- $publisher = $_POST['updatepublisher'];
- $img = $_POST['updateimg'];
- $update = "UPDATE Books SET PublishDate='$pubdate', Title='$title', Publisher='$publisher', Image='$img' WHERE BookID = ".$bookid;
- $conn->query($update) or die("Cannot update");
- }
- ?>
- <?php
- $sql = "SELECT * FROM Books WHERE BookID = '".$bookid."'";
- $result = $conn->query($sql) or die(mysql_error());
- $query=getenv(QUERY_STRING);
- parse_str($query);
- ?>
- <h2>Update Record <?php echo $bookid;?></h2>
- <form action="" method="post">
- <?php
- while ($row = $result->fetch_assoc()) {?>
- <table border="0" cellspacing="10">
- <tr>
- <td>Title:</td> <td><input type="text" name="updatetitle" value="<?php echo $row['Title']; ?>"></td>
- </tr>
- <tr>
- <td>Publisher:</td> <td><input type="text" name="updatepublisher" value="<?php echo $row['Publisher']; ?>"></td>
- </tr>
- <tr>
- <td>Publish Date:</td> <td><input type="text" name="updatepubdate" value="<?php echo $row['PublishDate']; ?>"></td>
- </tr>
- <tr>
- <td>Image URL:</td> <td><input type="text" name="updateimg" size="100" value="<?php echo $row['Image']; ?>"></td>
- </tr>
- <tr>
- <td><INPUT TYPE="Submit" VALUE="Update the Record" NAME="Submit"></td>
- </tr>
- </table>
- <?php }
- ?>
- </form>
- <?php
- if($update){
- echo "<b>Update successful!</b>";
- }
- ?>
- </body>
- </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement