title: How to query the max id from mysql?
body: <p>I have search some resources, but I still unable to make it. I would like to retrieve the data from the max id. I have some codes in .php to make query</p>
  
  <pre><code>&lt;?php
  
  $DB_HostName = "mysql8.000webhost.com";
  $DB_Name = "";
  $DB_User = "";
  $DB_Pass = "";
  $DB_Table = "";
  
  $con = mysql_connect($DB_HostName,$DB_User,$DB_Pass) or die(mysql_error()); 
  mysql_select_db($DB_Name,$con) or die(mysql_error()); 
  
  $query = "SELECT MAX(id),recommendData,room,level  FROM $DB_Table";
  
  $res = mysql_query($query,$con) or die(mysql_error());
  
  mysql_close($con);
  
  $rows = array();
  
  while ($r = mysql_fetch_assoc($res))
  {
      $row["maxid"] = array(
          "level" =&gt; $r["level"],
          "recommendData" =&gt; $r["recommendData"],
          "room" =&gt; $r["room"],
          "id" =&gt; $r["MAX(id)"]
      );
  }
  
  header('Content-type: application/json');
  
  echo json_encode($row);
  die;
  ?&gt;
  </code></pre>
  
  <p>the result shows like this:</p>
  
  <pre><code>{"maxid":{"level":"2","recommendData":"8","room":"4F","id":"4"}}
  </code></pre>
  
  <p>the the id is right, but data of level, recommendData, room are from the first id. Do I make something wrong??</p>