メンバーテーブルにデータを挿入します。挿入したばかりの情報のuserIDを取得します。これを行うための最良の方法は何ですか?最後に挿入された値のIDを返します。SQL
私のPHPコードが
//Insert info into database
$sql = "INSERT INTO members (type, firstname, lastname, email, password, bio) VALUES ('$usertype', '$firstname', '$lastname', '$emailsighup', '$passwordsighnup', '$bio')";
//Run a query to check if data has been inserted correctly.
$records = mysqli_query($connect, $sql);
私はこのSQLを試してみましたが、エラー
$sql = "INSERT INTO members (type, firstname, lastname, email, password, bio) VALUES ('$usertype', '$firstname', '$lastname', '$emailsighup', '$passwordsighnup', '$bio')"; SELECT SCOPE_IDENTITY(userID);
あなたは 'mysqli_insert_id($ connect);を試してください。 ' – Saty
すばらしい感謝はそれが簡単なことであると気付かなかった! – Ryan