Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- $servername = "localhost";
- $username = "root";
- $password = "";
- $dbname = "test";
- // Create connection
- $conn = new mysqli($servername, $username, $password, $dbname);
- // Check connection
- if ($conn->connect_error) {
- die("Connection failed: " . $conn->connect_error);
- }
- if(isset($_REQUEST['id'])){
- $id=intval($_REQUEST['id']);
- $comment=$_REQUEST['comment'];
- $sql = "UPDATE `table1` SET `comment` = '$comment' WHERE `table1`.`id` = $id;";
- $result = $conn->query($sql);
- }
- $sql = "SELECT * FROM table1";
- $result = $conn->query($sql);
- ?>
- <form>
- <?php
- $row = $result->fetch_assoc();
- echo '<input type="hidden" name="id" value="'.$row["id"].'">';
- echo '<textarea name="comment" rows="4" cols="50">'.$row["comment"]. "</textarea>";
- $conn->close();
- ?>
- <input type="submit"/>
- </form>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement