最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

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

programmeradmin0浏览0评论

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;
发布评论

评论列表(0)

  1. 暂无评论