I have a simple form where I am dynamically inserting the values from one MySQL table:
<input type="text" name="title" value="1" size="45">
This value=”1″ is coming from one MySQL table whose id parameter is auto-incrementing. So after id=1 it is 2,3,4,5,6,7,8,9 etc
When I submit the form, it is again reloaded but I want the id to be 2 next time. Then the third time, it should be 3, then 4, then 5, etc…
$res16 = sql_query("select * from mlf2_entries order by id desc limit 1 ");
$row = sql_fetch_array($res16);
$textqb = $row['id'];
^
I tried this but it always displays value=”1″
What you can do is use the offset feature in MySQL’s
LIMITclause to get the next row. This also accounts for any sequential gaps there may be in theidfield:^ This gets the first row in ascending order of the
idfield.The first number in
LIMITclause is the offset. The second number being the number of rows returned (you only want one row, so you can leave that number the same).To offset to the second row, do
LIMIT 1,1… to offset to the third row:LIMIT 2,1, and so forth and so on.