I have been working on this php to grab data from my MySQL database but it is unable to show results it just prints
Our connection is ok! 0 results
There are records in the database and the query works if I run it in phpMyAdmin. But it is unable to read it

  <?php
  $server = 'localhost';
  $pass = 'Blah';
  $user = 'Blah';
  $dbName = 'Blah';
  $db = new mysqli($server, $user, $pass, $dbName);
  if ($db->ping()) {
      printf ("Our connection is ok!\n");
  } else {
      printf ("Error: %s\n", $db->error);
  }
  if ($_GET['t'] == 'PL'){
      $table = 'Planets';
  } elseif ($_GET['t'] == 'SY') {
      $table = 'Systems';
  }elseif ($_GET['t'] == 'ST'){
      $table = 'Stars';
  }  else{
  };
$sql = "SELECT * FROM Planets WHERE ID =3";
$results = $db->query($sql);
if ($result->num_rows > 0) {
    // output data of each row
    while($row = $result->fetch_assoc()) {
        echo $row["ID"];
      };
} else {
    echo "0 results";
};
?>
Of course I have changed passwords and database details but they are correct in my version
