PHP/MySQL insert row then get 'id'

前端 未结 10 1058
臣服心动
臣服心动 2020-11-22 16:03

The \'id\' field of my table auto increases when I insert a row. I want to insert a row and then get that ID.

I would do it just as I said it, but is there a way I c

10条回答
  •  予麋鹿
    予麋鹿 (楼主)
    2020-11-22 16:44

    I found an answer in the above link http://php.net/manual/en/function.mysql-insert-id.php

    The answer is:

    mysql_query("INSERT INTO tablename (columnname) values ('$value')");        
    echo $Id=mysql_insert_id();
    

提交回复
热议问题