Select index from last inserted item.


/ Published in: PHP
Save to your folder(s)

Select the last autoincrement index from the last inserted item in a table.


Copy this code and paste it in your HTML
  1. //Bloqueamos la tabla
  2. mysql_query("LOCK TABLES myTable WRITE");
  3. //Hacemos el insert
  4. mysql_query("INSERT INTO myTable ......");
  5. //Obtenemos el id del proyecto
  6. $result_id=mysql_query("SELECT LAST_INSERT_ID()");
  7. define('MY_ID',mysql_fetch_row($result_id));
  8. //Desbloqueamos
  9. mysql_query("UNLOCK TABLES");

Report this snippet


Comments

RSS Icon Subscribe to comments

You need to login to post a comment.