wpdb query with dynamic column name?
This is simply a syntax error by the looks of it. You are using ” to open the string, and ‘ to close it. Use this: $which_column = ‘phone’; $data_check = $wpdb->get_var(“SELECT ” . $which_column . ” FROM wp_shopping_preferences WHERE wp_user_id = ‘$id'”); Fun fact: when using double quotes (“), you can directed insert a … Read more