PHP + MySql get the ID value of the newly added record 1. assume that the field name is recordID2. the field attribute must be set to auto_increment3. after adding data, use $ newIDmysql_insert_id (); obtain the ID value ASP to obtain the Real-Time ID value ASP + Access20001. the property of the ID value field to be obtained must be set to automatic
PHP + MySql get the ID value of the newly added record 1. assume that the field name is recordID 2. the field attribute must be set to auto_increment 3. after adding data, use $ newID = mysql_insert_id (); obtain the ID value ASP to obtain the Real-Time ID value ASP + Access2000 1. the property of the ID value field to be obtained must be set to automatic
PHP + MySql get the ID of the newly added record
PHP + MySql get the ID of the newly added record
1. Assume that the field name is recordID
2. The field attribute must be set to auto_increment.
3. After adding data, use
$ NewID = mysql_insert_id ();
Obtain the ID value.
ASP get real-time ID value
ASP + Access2000
1. The property of the ID value field to be obtained must be set to: automatic number (we assume that the field name is recordID)
2. Add record format: Rs. Open table, Cn, 1, 3
Note: 1, 3
3. newID = rs. Fields ("recordID ")
4. newID is the ID value of the newly added record.
ASP/SQL Server 2000
1. The property of the ID value field to be obtained must be set to: automatic number (we assume that the field name is recordID)
2. Add record code mode:
Cn. Execute "insert into table (field1, field2,...) VALUES (" field1Value "," field2Value ",...)"
3. Obtain the ID value.
Set Rss = Cn. Execute ("SELECT SCOPE_IDENTITY () as newIDValue FROM table ")
'Rs. Open sqlStr, Cn, 3, 1
NewID = Rss ("newIDValue ")
4. newID is the ID value of the newly added record.
5. Attach three methods to obtain the ID value:
/* It is best to use IDENT_CURRENT ('tbname ')*/
Insert into table (field1, field2,...) VALUES ("field1Value", "field2Value",...) SELECT IDENT_CURRENT ('recordid') as newIDValue
/* Use SCOPE_IDENTITY () for the newly inserted Record ID that is used immediately */
Insert into table (field1, field2,...) VALUES ("field1Value", "field2Value",...) SELECT SCOPE_IDENTITY () as newIDValue
/* It is best to use @ IDENTITY */for the auto-increment ID obtained in a series of operations */
Insert into table (field1, field2,...) VALUES ("field1Value", "field2Value",...) SELECT @ IDENTITY as newIDValu
Original article address: PHP + MySql obtains the ID value of the newly added record. Thank you for sharing it with the original author.