如何在foreach循环中实现选择查询我正在从数组中选择ID并在选择查询中传递
$query_user= "SELECT user_id FROM wp_usermeta WHERE meta_key='devstate' AND meta_value='$user_state'";
$query_value= $wpdb->get_row($query_user, OBJECT);
$user_id_value= $query_value->user_id;
$result = $wpdb->get_results($query_user) or die(mysql_error());
foreach( $result as $results ) {
$id=$results->user_id;
echo $id;
$my_query="SELECT * FROM $table where ID='$id'";
$val123= $wpdb->get_row($my_query, OBJECT);
$email123= $val123->user_email;
echo $email123;
echo $val123->user_email;
}
答案 0 :(得分:0)
您是否尝试过像这样传递变量:
$my_query="SELECT * FROM $table where ID=". $id;
或者尝试像这样转储选择变量:
echo($my_query);