title: Retrieve table ID from selected row
body: <p>So I've been stuck on this for a while and I can't find anything on google for this <em>specific</em> thing.</p>
  
  <p>I have this small snippet of code</p>
  
  <pre><code>$link = mysqli_connect("localhost", 'username','password',"database");
  $sql = "SELECT * FROM `uploads` ORDER BY id DESC LIMIT 0, 1";
  </code></pre>
  
  <p>Which <em>should</em> select the latest table by order of id's right?
  Well what I want to do is return this id. So if I have 5 items/rows I want to grab the latest (5 in this case) id of the table, and return it. With the eventual goal of using this returned id in javascript but that's a worry for later, right now I just want it in plaintext where the result should <em>only</em> be the id.</p>
  
  <p>This is probably a duplicate question but I can't for the life of me find what I should google to get there</p>
  
  <p><strong>EDIT:</strong></p>
  
  <p>I guess I should clarify further. I know I'm able to do </p>
  
  <pre><code>$sql = "SELECT ID FROM `uploads` ORDER BY id DESC LIMIT 0, 1";
  </code></pre>
  
  <p>but whenever I try to actually retrieve it/print it its returned as a string instead of the ID.</p>
  
  <p>EDIT 2: I, thanks to some comments, have managed to figure it out. Sorry for the badly worded everything, I'm new to this and as I said don't know how to word it.</p>
  
  <p>SOLUTION:</p>
  
  <p>After just throwing away the $sql thing I added:</p>
  
  <pre><code>$result = mysqli_query($link,"SELECT * FROM `uploads`"); 
  </code></pre>
  
  <p>Then I simply did </p>
  
  <pre><code>echo mysqli_num_rows($result); 
  </code></pre>
  
  <p>To echo out the number of rows/what I called the "ID".</p>
  
  <p>Sorry for all the confusion, thanks to those that tried to help. To the others there's no need to be rude.</p>