title: MySQL to table on website (mistake in code)
body: <p>I am trying to write a code to extract data from my MySQL database to a table on my website, I managed to setup a connection because it doesn't give me the failed to connect error, however the echo is just showing me the lines of code I wrote. I must have done something wrong.</p>
  
  <p>The code I have:</p>
  
  <pre><code>&lt;?php
  $con=mysqli_connect("IP","username","password","db name");
  // Check connection
  if (mysqli_connect_errno())
    {
    echo "Failed to connect to MySQL: " . mysqli_connect_error();
    } 
  
  $sql = "SELECT DISTINCT lastDisplayName FROM ranks ORDER BY `points` DESC     LIMIT 10";
  $result = $con-&gt;query($sql);
  
  if ($result-&gt;num_rows &gt; 0) 
    {
  // output data of each row
  while($row = $result-&gt;fetch_assoc()) {
      echo "id: " . $row["id"]. " - Name: " . $row["lastDisplayName"]. " " .$row["points"]. "&lt;br&gt;";
    }
  } else {
  echo "0 results";
  }
  mysqli_close($con);
  ?&gt;
  </code></pre>
  
  <p>I am a beginner and I made this code by viewing several online tutorials.</p>
  
  <p>Edit: I dont really think someone has the exact same code with the exact same mistake. Thereby I do not think this question is a duplicate.</p>