I am trying to update my custom table in WordPress using the following php code but still no success:
$tablename = "wpfeedback";
$data = array(
'mark' => $mark,
'comment' => $feedback_comment
);
$format= array('%s','%s');
$where = array( 'main_id' => $main_id );
$wpdb->update($tablename, $data, $where, $format);
When trying to update the data:
positive -> negative AND
Test 1: New post -> Test 2: Edit post
After var_dump( $wpdb->last_query )
, the result:
string(98) "UPDATE `wpfeedback` SET `mark` = 'positive', `comment` = 'Test 1: New post' WHERE `main_id` = '34'"
The above usage of $wpdb
. The problem I had was I put wrong vars on the input and textarea that’s why it seems not updating. Good thing I used var_dump()
. Thank you for the help @Milo!