I've used wp_send_json() to send the currently posted form data but cannot find a way to send the id attached to it which is incremented automatically from the database,, so that i can update the table data on the page without refreshing...

enter image description hereenter image description here


From an example in the Developer Reference:

To get the id of the inserted object use $wpdb->insert_id;

global $wpdb;
$table = $wpdb->prefix.'you_table_name';
$data = array('column1' => 'data one', 'column2' => 123);
$format = array('%s','%d');
$my_id = $wpdb->insert_id;
  • Thank you so much man.. This is so helpful. – Bikash Gurung May 15 '19 at 18:46
  • If this is helpful, you should mark it as the answer. :-) – MikeNGarrett May 15 '19 at 20:18

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.