Guest User

show.php

a guest
Jan 16th, 2019
63
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 1.20 KB | None | 0 0
  1. <?php
  2. /**
  3.  * Created by PhpStorm.
  4.  * User: Cod.wiz
  5.  * Date: 1/16/2019
  6.  * Time: 9:56 PM
  7.  */
  8.  
  9.  
  10. $servername = "localhost";
  11. $username = "root";
  12. $password = "";
  13. $dbname = "mydb";
  14.  
  15. $conn = new mysqli($servername, $username, $password, $dbname);
  16. if ($conn->connect_error) {
  17.     die("Connection failed: " . $conn->connect_error);
  18. }
  19.  
  20. // form is the column (double checked it)
  21. $sql = "SELECT * FROM form;";
  22. // was getting a $conn not defined error which resides into another file , had included it with include_once "connect.php". But error so moved the
  23. // code here
  24. $result = mysqli_query($conn, $sql);
  25. $resultCheck = mysqli_num_rows($result);
  26.  
  27. // below is the line 27
  28.     if ($resultCheck > 0) {
  29.         while ($row = mysqli_fetch_assoc($result)) {
  30.             // value1 is the row name from which I want to show data from
  31.             echo $row['value1' . '<br>'];
  32.         }
  33.     }
  34.  
  35.      /*
  36.  
  37. Notice: Undefined index: id
  38. in C:\xampp\htdocs\form\show.php on line 27
  39.  
  40. Notice: Undefined index: id
  41. in C:\xampp\htdocs\form\show.php on line 27
  42.  
  43. Notice: Undefined index: id
  44. in C:\xampp\htdocs\form\show.php on line 27
  45.  
  46. Notice: Undefined index: id
  47. in C:\xampp\htdocs\form\show.php on line 27
  48.      */
Add Comment
Please, Sign In to add comment