Pleas add the error message you get, do you have error reporting turned on, there are some syntax errors that would stop the program immediately. Next to that you are calling bindParam on a string, that won't work either ;).
(Zag dit toevallig op fb, gtz, d)
Edit:
This is untested, but something like this is how it should work:
// I assume you have an instance of the pdo object? I will call it $db for convenience.
require_once 'conn.php';
$q = "SELECT Name, MAX(Count) AS MaxCount, ZIPcode, Year
FROM Name_Data
WHERE Year = :year";
if( isset( $_GET['dropdowngender'] ) && !empty( $_GET['dropdowngender']) ) {
$q .= " AND Gender = :gender";
}
$q .= " AND Name_Data.Count =
( SELECT MAX( Count ) FROM Name_Data AS f
WHERE f.id = Name_Data.id
) GROUP BY ZIPcode";
$stmt = $db->prepare($q);
$stmt->bindParam(':year', $_GET['dropdownyear'], PDO::PARAM_STR);
if( isset( $_GET['dropdowngender'] ) && !empty( $_GET['dropdowngender']) ) {
$stmt->bindParam(':gender', $_GET['dropdowngender'], PDO::PARAM_STR);
}
$stmt->execute();
$result = $stmt->fetchAll(PDO::FETCH_ASSOC);
$jsonResult = json_encode($result);
echo $jsonResult;