title: PHP SQL query to print results in webpage
body: <p>I am trying to get my PHP script to print all rows i have in my database in a neat order. Currently Im not getting anything. My table has 4 columns, Name, Address, Long and Lat, and 2 rows with data. The table is called Locations. I am using the following code but im not getting to to work:</p>
  
  <pre><code>&lt;?php
  
  $con=mysqli_connect("localhost","user","pass","db");
  
  if (mysqli_connect_errno()) {
    echo "Failed to connect to MySQL: " . mysqli_connect_error();
  }
  
  $sql = "SELECT * FROM `Locations` ";
  
  if ($result = mysqli_query($con, $sql))
  {
   $resultArray = array();
   $tempArray = array();
  
   while($row = $result-&gt;fetch_object())
   {
    $tempArray = $row;
       array_push($resultArray, $tempArray);
   }
  
   echo json_encode($resultArray);
  }
  
  // Close connections
  mysqli_close($con);
  ?&gt;
  </code></pre>