php - How can i send id of the currently posted form data through json response in custom wordpress plugin?

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

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...

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...

Share Improve this question asked May 15, 2019 at 17:07 Bikash GurungBikash Gurung 213 bronze badges
Add a comment  | 

1 Answer 1

Reset to default 0

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');
$wpdb->insert($table,$data,$format);
$my_id = $wpdb->insert_id;

发布者:admin,转转请注明出处:http://www.yc00.com/questions/1745490264a4629956.html

相关推荐

发表回复

评论列表(0条)

  • 暂无评论

联系我们

400-800-8888

在线咨询: QQ交谈

邮件:admin@example.com

工作时间:周一至周五,9:30-18:30,节假日休息

关注微信