Advertisement
Guest User

Untitled

a guest
Feb 18th, 2017
104
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.86 KB | None | 0 0
  1. <html lang="en">
  2. <head>
  3. <meta charset="utf-8" />
  4. </head>
  5. <body onload = "showPeople();">
  6.  
  7. <div id="information"></div>
  8.  
  9. <script type="text/javascript">
  10.  
  11. function showPeople()
  12. {
  13. "<?php require 'app.php';?>"
  14.  
  15. var datos = "<?php showCustomers();?>";
  16. document.getElementById("information").innerHTML = datos;
  17. }
  18.  
  19. </script>
  20. </body>
  21. </html>
  22.  
  23. <?php
  24.  
  25. function showCustomers(){
  26.  
  27. require "conexion.php";
  28.  
  29. $result = mysqli_query($con,"SELECT * FROM users");
  30.  
  31. while($row = mysqli_fetch_assoc($result))
  32. {
  33. echo '<br />'.$row['name'];
  34. }
  35.  
  36. mysqli_close($con);
  37. }
  38.  
  39. ?>
  40.  
  41. <?php
  42. $mysql_host = 'localhost';
  43. $mysql_user = 'root';
  44. $mysql_pass = 'root';
  45. $mysql_db = 'Customers';
  46.  
  47. $con = mysqli_connect($mysql_host,$mysql_user,$mysql_pass,$mysql_db);
  48.  
  49. if (mysqli_connect_errno())
  50. {
  51. echo "Failed to connect to MySQL: " . mysqli_connect_error();
  52. }
  53. else{
  54. echo "Connected";
  55. }
  56. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement