Assign Max() MySQL command to a variable in PHP -



Assign Max() MySQL command to a variable in PHP -

in mysql database, insert entry db, , need number of lastly insertion. have set auto-increment. using query "select max(id) table;" works fine in database, need capture number variable in php.

$rowsql = mysqli_query($con, "select max(id) table"); $row = mysqli_fetch_assoc($rowsql); $largestuid = $row['max']; echo $largestuid;

thanks help!

use as modifier in query. modifier gives selected items alias.

$rowsql = mysqli_query($con, "select max(id) maxid table"); $row = mysqli_fetch_assoc($rowsql); $largestuid = $row['maxid']; echo $largestuid;

php mysql sql mysqli

Comments

Popular posts from this blog

xslt - DocBook 5 to PDF transform failing with error: "fo:flow" is missing child elements. Required content model: marker* -

mediawiki - How do I insert tables inside infoboxes on Wikia pages? -

Local Service User Logged into Windows -