php - Using next AUTO_INCREMENT id within query? -
php - Using next AUTO_INCREMENT id within query? -
i know similar questions have been asked, none of them seem work i'm attempting.
i'm developing scheme mysqli/php takes sound files, uploads them, renames them, , stores name. problem is... need name of file "uploadedfile_[$id_here].mp3"
i've got entire upload scheme working properly, i'm on lastly step... getting id work.
the id column in table auto_increment. need find out how "predict" auto_increment id given upcoming new row , tag on end of sound file name means of variable.
one method i've attempted is:
$result = mysqli_query($conn, "show table status 'test_table'"); $row = mysqli_fetch_array($result); $nextid = $row['auto_increment']; print $nextid;
but doesn't homecoming results. connections file should configured i've used other queries , works fine.
thanks in advance!
it depends on how frequent code run, surely?
auto-incrementation works increasing 1 each time. record inserted, i've started php myself certainly add together 1 your...
$nextid = $row['auto_increment'];
which give next id coming up. unless, maerlyn stated, have 2 users @ same time, in case think insert temp table whilst record beingness inserted, , if succeeds, inset main table , remove temp table. when inserting temp table you'd first have run check see if record exists in temp table before attempting anything.
just 2 cents.
php mysqli auto-increment
Comments
Post a Comment