I have a function in php that does retrieval and display work from a MySql database.

It's like this:

  function thisFunction($id,$country,$year){
    global $conn;
    	$conn = connect();
    	$stmt = $conn->prepare("select * from table where id = :id and countryCode = :country and YEAR(addedDate) = :year and status = 0");
    		':id'      => $id,             
    		':country' => $location,
    		':year'    => $year
The problem is, sometimes
has a value, sometimes it doesn't. When it does have a value, I'd like to select records with that value, when it doesn't I'd like to select all.

How do I write the sql in there, or do this thing, so that when there is a value it'll select only records with that value, and when there isn't a value, it'll select all. It's the part where when no value is selected - then select all where I'm stuck.

I call the function like anyone would. Nothing unique there.

  select * from table where id = 9 -- works fine - displays all records where id = 9
    select * from table where id = no value supplies - should display all value. How do I do this?
Can you please help?

 select * from table where id = * //Does not work
There's nothing in MySql like id = * or id = NULL. Something like that that'll get all values when no figure is supplied