Ok, don't know if this is simple in practice as it is in theory but I want to know.
I have a single INSERT
query were by in that query, i want to extract the AUTO_INCREMENT
value then reuse it in the same query.
For example
//values to be inserted in database table
$a_name = $mysqli->real_escape_string($_POST['a_name']);
$details = $mysqli->real_escape_string($_POST['details']);
$display_type = $mysqli->real_escape_string($_POST['display_type']);
$getId = mysqli_insert_id();
//MySqli Insert Query
$insert_row = $mysqli->query("INSERT INTO articles (a_name,details,display_type,date_posted) VALUES('$a_name','$details','$display_type$getId',CURRENT_TIMESTAMP)");
Apparently, am getting a blank value
(I know because the mysqli_insert_id()
is before the query, but I've tried all i could but nothing has come out as i want. Can some please help me on how to achive this