mysqli auto incremented primary id that was generated

前端 未结 2 964
不知归路
不知归路 2021-01-20 14:48
$insert = \"INSERT INTO event_tracker_table (event_name, event_location, location_number, event_creator_username, event_creator_email)

            VALUES (
                 


        
相关标签:
2条回答
  • 2021-01-20 15:17

    Insert id is a property of the MYSQLI object and not the MYSQLI result object:

    $statement = $mysqli->query($insert);
    echo $mysqli->insert_id; // correct
    echo $statement->insert_id; //not correct
    

    http://php.net/manual/en/mysqli.insert-id.php

    0 讨论(0)
  • 2021-01-20 15:19

    You can get the auto_increment value with

    $id = mysqli_insert_id($mysqli);
    

    See mysqli_insert_id for more info.

    0 讨论(0)
提交回复
热议问题