我想將圖像與名字,姓氏相關聯(lián)...如何檢索最后一行并將其插入到另一個表中?我試過$image = $mysqli->insert_id;然后綁定,但不起作用。有人可以幫我嗎? $image = $mysqli->insert_id;//this should come from table2 $stmt = $mysqli->prepare(" insert into table1 (username, firstname, lastname, image) select ?,?,?,image from table2 t2 where username = ? and t2.id = ? "); $stmt->bind_param('sssss', $username, $fname, $lname, $username, $image); $stmt->execute();
3 回答

慕森王
TA貢獻1777條經驗 獲得超3個贊
首先,您需要在ID中創(chuàng)建auto_increment字段
然后你可以用 $last_id = mysqli_insert_id($conn);
添加回答
舉報
0/150
提交
取消