I've MySQL Table with Primary key as AUTO_INCREAMENTED (UNSIGNED INT) as sequence number. Every Time I insert new row in this table, I want to give acknowledgement to the user showing inserted AUTO_INCREAMENTED UNSIGNED INT.
Currently after inserting row, I’m executing SELECT Query to get last inserted row. Is there any smarter way to get inserted value, immediately after INSERT (without SELECT) ?
Try with
mysql_insert_id()Refer THIS for more about
mysql_insert_id()And Try to avoid
mysql_*statements due to the entireext/mysql PHPextension, which provides all functions named with the prefixmysql_*, is officially deprecated as ofPHP v5.5.0and will be removed in the future.There are two other
MySQLextensions that you can better Use:MySQLiandPDO_MySQL, either of which can be used instead ofext/mysql.In
mysqli_*it will be like