mysql - How to use PHP display data of last insert row of a specific column -


i have table in database 2 columns, id(auto increment) , name.

id|name --|---- 1 |john 2 |jeff 3 |jack  

i wish show last insert name in webpage can echo "the last person $last_name";

i try retrieve data using following command, shows nothing.

$last_name = mysqli_query($conn, 'select name namelist order id desc limit 1') 

someone please help? thank you.

try this...

if procedural

$query = "insert mycity values (null, 'stuttgart', 'deu', 'stuttgart', 617000)"; mysqli_query($conn, $query); mysqli_insert_id($conn) 

if object oriented

$query = "insert mycity values (null, 'stuttgart', 'deu', 'stuttgart', 617000)"; $mysqli->query($query); $mysqli->insert_id 

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


Comments

Popular posts from this blog

python - How to insert QWidgets in the middle of a Layout? -

python - serve multiple gunicorn django instances under nginx ubuntu -

module - Prestashop displayPaymentReturn hook url -