Update/insert only a column of database table

You’re using $wpdb->where() incorrectly.

In your code, $data_array and $data_where are going to be exactly the same, so if we assume that $_POST['getval'] is 1, the resulting query will be:

UPDATE wp_fes_vendors SET requests=1 WHERE requests=1

You see how that doesn’t make sense? It’s setting the requests column to 1 for all rows where requests is already 1. It’s a query that will never actually do anything.

The correct way to use $wpdb->where() is to make sure that $data_array contains the column names, and the new values that you want to set them to, while $data_where should contain columns and values to use to identify which row should be updated.

For example, if I want to set requests to 1 for the vendor with the ID of 5, I need to do this:

$data_array = array(
    'requests' => 1
);

$data_where = array(
    'id' => 5
);

$wpdb->update( $table_name, $data_array, $data_where );

The result of that query will be:

UPDATE wp_fes_vendors SET requests=` WHERE id=5

So this means that in your form, you need to POST both the new value of the column, as well as the ID of the vendor that you need to update.

techhipbettruvabetnorabahisbahis forumuedusedusedueduedusedusedueduseduedus