Advertisement
Eamesy

PHP reader

May 22nd, 2019
162
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 0.73 KB | None | 0 0
  1. <?php
  2. $host = 'dominicclustersql.mysql.database.azure.com';
  3. $username = 'dominic@dominicclustersql';
  4. $password = 'Dom90madd';
  5. $db_name = 'clusterresults';
  6.  
  7. //Establishes the connection
  8. $conn = mysqli_init();
  9. mysqli_real_connect($conn, $host, $username, $password, $db_name, 3306);
  10. if (mysqli_connect_errno($conn)) {
  11. die('Failed to connect to MySQL: '.mysqli_connect_error());
  12. }
  13.  
  14. //Run the Select query
  15. printf("Reading data from table: \n");
  16. $res = mysqli_query($conn, 'SELECT * FROM wordcount');
  17. while ($row = mysqli_fetch_assoc($res)) {
  18.     $field1name = $row["word"];
  19.     $field2name = $row["count"];
  20.  
  21.     echo '<br>'.$field1name." Repeats: ".$field2name." times".'</br>';
  22. }
  23.  
  24. //Close the connection
  25. mysqli_close($conn);
  26. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement