Getting a the latest field entry for auto increment in PHP

By: J Bug | Asked: 02/15/2023
ForumsCategory: General questionsGetting a the latest field entry for auto increment in PHP
J Bug asked 2 years ago
Hi everyone, Im trying to create a form entry via PHP - and in the original form, I have an [auto_id] increment for one of the fields..

When I create one manually via PHP, how do I get the field to also go up 1, based on the last entry that was created for that field?

I cant seem to locate the PHP to pull that number, and then just +1 to it...

Any help? Thank you!
1 Answers
Rob LeVineRob LeVine answered 2 years ago
While you'll ultimately make the call in PHP, it's a MySQL command you're looking for something like this
SELECT auto_increment FROM information_schema.tables WHERE table_name='<your table name>';

Making the Best WordPress Plugin even better - Together

Take on bigger projects with confidence knowing you have access to an entire community of Formidable Experts and Professionals who have your back when the going gets tough. You got this!
Join the community
crossarrow-right