有点难猜,你到底想实现什么,但是。。。根据您的回答,以下是更简洁、更安全的代码,您可以使用:
global $wpdb;
$usernames = $wpdb->get_results(
$wpdb->prepare(
"SELECT user_name FROM {$wpdb->prefix}project_members WHERE project_id = %d",
698
)
);
if ( ! empty($usernames) ) {
echo $usernames[0]->user_name;
} else {
// there are no users
}