I have a list of countries in a dropdown, that when selected, filter the data down to posts within that country.
The problem
I have an 'All' option in the select
input box, but not sure how to go about retrieving all the data using PDO.
The problem I am having is when it comes to binding the data using PDO. How can I configure it so it can accept an all value?
[Note: data comes through jquery AJAX
]
Code
// HTML
<select name ="Country">
<option value="">All</option>
<option value="United Kingdom">United Kingdom</option>
/* the rest **/
</select>
// PHP
// {$conn->tbl_Table} is a reference to a key linking to a value table
$fetchQ = $conn->dbConn->prepare("
SELECT *
FROM {$conn->table_Table}
WHERE
Country :Country");
$fetchQ->execute(array(
"Country"=>$_POST['Country']
));