title: PHP PDO Max Value
body: <p>So let's say I have a column called groupID, it is a number given to a group of people. Basically all I want to do is get the largest value from that column, add 1 and store that input into a variable in php.</p>
  
  <p>For example, if the last group's id was 5, then the next group's id should be 6. Any ideas? </p>
  
  <pre><code>$gid = $link-&gt;prepare("SELECT MAX(Group_ID) FROM Conference");
  $gid-&gt;execute();
  $groupid = $gid-&gt;fetchColumn();
  
  $stmt = $link -&gt; prepare("INSERT INTO Conference (`Group_ID`) VALUES (:groupid)");
  $stmt-&gt;bindParam(':groupid', $groupid);
  $stmt-&gt;execute();
  </code></pre>