Lets assume my database has a table called "inventory", with rows ID and name.
The ID is an int > 1000. I need to increment this number when inventory is input on a form. I have MySQL setup to increment this number, no big deal.
My problem: when a user reaches the input screen, the new number (last ID input + 1) needs to appear. I can't figure out an easy way to get the last row.
I'm thinking it's something along the lines of:
$inv_q = mysql_query ("SELECT ID FROM inventory");
$rows = mysql_num_rows ($inv_q);
$cnt = 0;
while ($cnt < $rows) {
while ($inv = mysql_fetch_array($inv_q)) {
if ($cnt == $rows) {
$lastID = $inv['ID'];
}
}
$cnt++;
}
$newID = $lastID + 1;
Any Ideas?