php - Get last ID after SQL insert -
Below this code, some data is included in a MySQL database. After inserting the page is loaded on this record , But the variable ($ insertion) I'm trying to load is at the top. Can anyone help?
$ pdo = Database :: connect (); $ Pdo- & gt; Set Attribution (PDO :: ATTRRAMOD, PDO :: ERMMDMEXEPEPS); $ Sql = "Rider (first name, second name, email, mobile, landline, dub, adressline 1, city, county, postcode) values (?,?,?,?,?,?,?,?,?,?,?, ?) "; $ Q = $ pdo- & gt; Ready ($ sql); $ Q- & gt; Execute (array ($ firstname, $ secondname, $ email, $ mobile, $ landline, $ birth date, $ streetaddress, $ city, $ county, $ postcode)); $ Insert = mysql_insert_id (); Database :: Disconnect (); Header ("Place: .add.php ID = $ insert"); Use $ pdo->
LastInsertId () is getting the last id after inserting SQL.
Comments
Post a Comment