需要从按钮单击数据库中获取最后插入的ID ...按钮单击后会有一个新页面...在此页面上我想打印最后插入+ 1表示下一个ID ...请帮助我
<a href="index.php"><button type="button" class="btn btn-warning">ADD MEMBER</button></a>
&#13;
答案 0 :(得分:0)
嗨简单的mysqli
内置function
用于此
成功后insertion
只需拨打此function
if (mysqli_query($conn, $sql)) {
$last_id = mysqli_insert_id($conn);
}
或如评论中所述,您还可以query
运行last inseted id
if (mysqli_query($conn, $sql)) {
$result= mysqli_query($con ,"SELECT id FROM Table_name ORDER BY id DESC LIMIT 1 ");
$row = mysqli_fetch_assoc($result);
$last_id = $row['id'];
}
答案 1 :(得分:0)
$ result = mysqli_query(“SELECT * from tablename where id ='”。mysqli_insert_id($ conn)。“'”);