I am attempting to select details from a table using multiple strings from another table in Wordpress.
The first table has project details which are assigned to clients and the second table has the client details. There may be more than one client assigned to a particular project. So I need to find a loop that will work in this instance, as currently it only displays one client’s details
The code is as follows:
$clients=$wpdb->get_results($wpdb->prepare( " SELECT * FROM vo_wp_assigned_projects where project=‘$project_id’"));
foreach($clients as $list){
$project=$list ->project;
$client=$list ->client;
$id=$list->client_id;
$name=$list->name;
$users=$wpdb->get_results($wpdb->prepare(" SELECT * FROM vo_wp_clients where user_id =‘$id’"));
foreach($users as $user){
$users_id=$user ->user_id;//echo $users_id;
$client=$user->user_name;
$title=$user->user_title;
$phone=$user ->user_info;//echo $phone;
$email=$user ->user_email;
}
}
What am I missing here