Possible Duplicate:
Incrementing a field in SQL using PHP
I have a table (T1) with some fields F2, F3 (Columns) with already some values in it …. .
I need to add a new field (F1) to the table (T1) and F1 will be the primary key .
The field type F1 is a integer .
I assigned a random 8 digit number to the first row of F1 and the remaining rows should be incremented by 1 from the previous row. This increment should go in par with the other fields F2 , F3 etc…
This F1 should also be increased if entirely new row is added to the table.
I tried to do it with lastinsertid() in PHP but it only works for rows which are newly created.
Can u ppl help me in writing the code for the above using lastinsertid().
If its not clear plzz let me know..
Just set the
primary keyof your table toauto_increment. Check this for more info