Pull from MySQL and display from table


/ Published in: MySQL
Save to your folder(s)

$connect = mysql_connect("localhost:8889", "root", "root");

This means you need your host, user, pass


Copy this code and paste it in your HTML
  1. <?php
  2.  
  3. $connect = mysql_connect("localhost:8889", "root", "root");
  4.  
  5. if(!$connect){
  6.  
  7. die("Failed to connect: " . mysql_error());
  8.  
  9. }
  10.  
  11. if(!mysql_select_db("ourDatavase")){
  12.  
  13. die("Failed to select DB:" . mysql_error());
  14.  
  15. }
  16.  
  17. $results = mysql_query("Select * FROM someData");
  18.  
  19. if(!$results){
  20. die("Failed to run query:" . mysql_error());
  21. }
  22.  
  23. while($row = mysql_fetch_array($results)){
  24.  
  25. echo $row['name'] . "<br/>";
  26.  
  27. }
  28.  
  29. ?>

Report this snippet


Comments

RSS Icon Subscribe to comments

You need to login to post a comment.