Home  >  Article  >  php教程  >  PHP获取Mysql插入记录后ID

PHP获取Mysql插入记录后ID

PHP中文网
PHP中文网Original
2016-05-25 17:13:421045browse

代码

$query="INSERT INTO `testtable` (`clou1`,`clou2`) VALUES ('testvalue','test')";
mysql_query($query);
$query="SELECT LAST_INSERT_ID()";
$result=mysql_query($query);
$rows=mysql_fetch_row($result);
echo $rows[0];
Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn