The $wpdb->query()
method doesn’t return query results but a count on how many rows were affected by the query. To get the results you have to user the $wpdb->get_results($sqlString)
method and then iterate over it.
<?php
function custom_user_profile_fields($profileuser) {
?>
<h1>Select a Category</h1>
<select name="category">
<?php
global $wpdb;
$terms = $wpdb->get_results( "SELECT name FROM wp_terms" );
foreach ( $terms as $term ) { ?>
<option value=""><?php echo $term->name; ?></option>
<?php }
?>
</select>
<?php
}
add_action('show_user_profile', 'custom_user_profile_fields');
add_action('edit_user_profile', 'custom_user_profile_fields');