Hello,
Thank you for your help, I already got it!
<?php
$gemeente = $_GET['gemeente'];
global $wpdb;
$results = $wpdb->get_results("SELECT location
, value
, COUNT(*) as total
FROM wp_rg_lead_detail
INNER JOIN
(
SELECT lead_id -- subquery to find location for the song choices
, value as location
FROM wp_rg_lead_detail
WHERE field_number = 11
) loc USING (lead_id)
WHERE field_number IN (8,16,20)
AND value <> 'Selecteer uw lied!'
AND location = '$gemeente ' -- remove this line for all locations
GROUP BY location, value -- and remove location from ORDER and GROUP
ORDER BY location, total DESC
LIMIT 10");
if(!empty($results)) {
foreach($results as $r) {
echo "<p>".$r->value."</p>";
}
} else {
echo "<p>Boo, we couldn't find anything that is in all these groups. Try removing a category!</p>";
}
?>
Now i can create a view for every Location based on the url i give in!
Thank you verry much!
Jeroen