I'm still learning PHP and MySQL and need to create a unique number in Wordpress site (as a order number ID) every time, when user fill and submit "order" form from frontend and save it to database. Next submit will create a number+1. Website is not running on Woocommerce. No cart, checkout, products...
Thanks for help! :)
I'm still learning PHP and MySQL and need to create a unique number in Wordpress site (as a order number ID) every time, when user fill and submit "order" form from frontend and save it to database. Next submit will create a number+1. Website is not running on Woocommerce. No cart, checkout, products...
Thanks for help! :)
in order to do this use
AUTO_INCREMENT PRIMARY KEY
while you define your table. Your table should be something like this:
CREATE TABLE `order` (
`order_id` INT(11) UNSIGNED AUTO_INCREMENT PRIMARY KEY,
`user_group_id` INT(11) UNSIGNED NOT NULL,
`status` BIT,
`meta` VARCHAR ( 255 ),
`value` TEXT,
`update_time` TIMESTAMP
)DEFAULT CHARSET = utf8;
remember that you could change other columns, the important one is order_id
which is auto increment
You can get the unique ID number by using the merge tag {submission:sequence}. It allows you to get the submission number of the current user’s submission.It only populates after the submission data has been saved to the database.