开发者

Incrementing a field in a SQL table using PHP [duplicate]

This question already has an answer here: Closed 11 years ago.

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 开发者_StackOverflow社区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 key of your table to auto_increment. Check this for more info

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜