Advertisement
Guest User

Untitled

a guest
Sep 28th, 2016
81
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 0.81 KB | None | 0 0
  1. <?php
  2. $servername = "localhost";
  3. $username = "root";
  4. $password = "";
  5. $dbname = "test";
  6.  
  7. // Create connection
  8. $conn = new mysqli($servername, $username, $password, $dbname);
  9. // Check connection
  10. if ($conn->connect_error) {
  11.     die("Connection failed: " . $conn->connect_error);
  12. }
  13.  
  14. if(isset($_REQUEST['id'])){
  15.     $id=intval($_REQUEST['id']);
  16.     $comment=$_REQUEST['comment'];
  17.     $sql = "UPDATE `table1` SET `comment` = '$comment' WHERE `table1`.`id` = $id;";
  18.     $result = $conn->query($sql);  
  19. }
  20.  
  21.  
  22. $sql = "SELECT * FROM table1";
  23. $result = $conn->query($sql);
  24. ?>
  25.  
  26. <form>
  27.  
  28. <?php
  29. $row = $result->fetch_assoc();
  30. echo '<input type="hidden" name="id" value="'.$row["id"].'">';
  31. echo '<textarea name="comment" rows="4" cols="50">'.$row["comment"]. "</textarea>";
  32. $conn->close();
  33. ?>
  34. <input type="submit"/>
  35. </form>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement