我想抓插入数据库最后一笔数据的ID(为主键递增),把这个ID变量传递到下一页面,方便获取使用,使用了
$select="select last_insert_id() ";来获取,此方法初次使用,导致不是报错就是抓空值,有请个位大虾,伸出援助之手
代码片段:
<?php
@ $db=new mysqli('localhost', 'bm_user', 'password', 'ivortt');
if (mysqli_connect_errno()){
echo "Connect Error: Could not connect to database. Please try again later.<br />";
exit;}
//insert values into table joblist
$query_info="insert into hr_jl(id,timecoll,college1,school_type,college,craft,degree,english,compute,interest,time_one,time_two,item_name,practice_responsibility0,description_practice0)
values
('".$id."','".$timecoll."','".$college1."','".$school_type."','".$college."','".$craft."','".$degree."','".$english."','".$compute."','".$interest."','".$time_one."','".$time_two."','".$item_name."','".$practice_responsibility0."','".$description_practice0."')";
$result=$db->query($query_info);
if($result) {
echo include("student_baseinfo.php?id=$id");
}else {
echo "Insert Error:An error has occurred. The item was not added.<br />";
}
$db->close();
?>
我该怎么使用last_insert_id()获得ID是值?
补充一下:
字段:ID
类型:BIGINT
AUTO_INCREMENT
Smart猫小萌
偶然的你