Advertisement
Guest User

Untitled

a guest
May 8th, 2018
90
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.84 KB | None | 0 0
  1. <?php
  2. // Server credentials
  3. $servername = "localhost";
  4. $username = "rustopsc_root";
  5. $password = "sV@3g%3WmTrg";
  6. $dbname = "rustopsc_root";
  7.  
  8. // Creating mysql connection
  9. $conn = new mysqli($servername, $username, $password, $dbname);
  10.  
  11. // Checking mysql connection
  12. if ($conn->connect_error) {
  13. die("Connection failed: " . $conn->connect_error);
  14. }
  15.  
  16. // Writing a mysql query to retrieve data
  17. $sql = "SELECT id, purchaser, lastname FROM transactions";
  18. $result = $conn->query($sql);
  19.  
  20. if ($result->num_rows > 0) {
  21. // Show each data returned by mysql
  22. while($row = $result->fetch_assoc()) {
  23. ?>
  24.  
  25. <!-- USING HTML HERE : Here I am using php within html tags -->
  26. <p> Name : <?php echo $row["purchaser"] . " " . $row["lastname"]; ?> </p>
  27.  
  28. <?php
  29. }
  30. } else {
  31. echo "0 results";
  32. }
  33.  
  34. // Closing mysql connection
  35. $conn->close();
  36. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement