如果我想$post->user_id
在这样的两个函数中使用该变量,它就不起作用。为什么?
foreach ($usermeta as $post) {
echo $post->user_id;
echo $post->name;
echo $post->team;
}
function nicoupdate($post->user_id) {
update_usermeta( $post->user_id , 'ptotali', $_POST['ptolti'] );
}
我不明白。
仍然不起作用:
$sql="SELECT `user_id`,
max(case when `meta_key` = 'name' then `meta_value` end) as name ,
max(case when `meta_key` = 'team' then `meta_value` end) as team ,
max(case when `meta_key` = 'ptotali' then `meta_value` end) as points ,
FROM wp_usermeta
GROUP BY `user_id`
ORDER BY points DESC";
global $wpdb;
$usermeta = $wpdb->get_results($sql) or die(mysql_error());
foreach ($usermeta as $post) {
echo $post->user_id;
echo $post->name;
echo $post->team;
}
function nicoupdate($user_id) {
update_usermeta( $user_id , 'ptotali', $_POST['ptolti'] );
}
怎么了?如果我手动输入 user_id 例如 3 它可以工作。