如何制作动态的月,日,年错误消息

I would like to make my form's month, day, year error text dynamic in a sense that if a user doesnt select month and day it will say "Please select a year". If a user doesn't select all three it will say "Please select a month, day, and year". If a user doesn't select a year it will say "Please select a year" and so on... Currently, my code just says "Please select a month" "Please select a day" "Please select a year" all side by side and I think I should fix this so it's more easy to read for a user. Here is what it looks like now: myformnow

<?php
#this does the exact same thing as NULL, this lets the user know to fill out their first name
if(($_POST['Month'] == "Month") && ($_SERVER['REQUEST_METHOD'] == 'POST')){
    echo "<strong>Please select a month! &nbsp</strong>";
}


if(($_POST['Day'] == "Day") && ($_SERVER['REQUEST_METHOD'] == 'POST')){
    echo "<strong>Please select a day! &nbsp</strong>";
}


if(($_POST['Year'] == "Year") && ($_SERVER['REQUEST_METHOD'] == 'POST')){
    echo "<strong>Please select a year! &nbsp</strong>";
}
?>
<br />
Date of Birth: 
<select name='Month'>
<?php
#this code makes the it so when the user selects a month and submit the form and they forget something their selection will still be selected
$months = array(0 => 'Month', 'January', 'February', 'March', 'April', 'May', 'June', 'July', 'August', 'September', 'October', 'November', 'December');

foreach($months as $monthsel) {
    if($_POST['Month'] == $monthsel) {
            $isselected = "selected";
    } else {
            $isselected = "";   
    }

echo "<option value='$monthsel' $isselected>$monthsel</option> 
";
}

?>
</select>



<select name='Day'>
<?php
#this code makes the it so when the user selects a month and submit the form and they forget something their selection will still be selected
$day = array(0 => 'Day', '1', '2', '3', '4', '5', '6', '7', '8', '9', '10', '11', '12', '13', '14', '15', '16', '17', '18', '19', '20', '21', '22', '23', '24', '25', '26', '27', '28', '29', '30', '31');

foreach($day as $daysel) {
    if($_POST['Day'] == $daysel) {
            $isselected = "selected";
    } else {
            $isselected = "";   
    }

echo "<option value='$daysel' $isselected>$daysel</option> 
";
}

echo "
";
?>
</select>

<select name='Year'>
<?php
#this code makes the it so when the user selects a month and submit the form and they forget something their selection will still be selected
$year = array(0 => 'Year', '2019', '2018', '2017', '2016', '2015', '2014', '2013', '2012', '2011', '2010', '2009', '2008', '2007', '2006', '2005', '2004', '2003', '2002', '2001', '2000', '1999', '1998', '1997', '1996', '1995', '1994', '1993', '1992', '1991', '1990', '1989', '1988', '1987', '1986', '1985', '1984', '1983', '1982', '1981', '1980', '1979', '1978', '1977', '1976', '1975', '1974', '1973', '1972', '1971', '1970', '1969', '1968', '1967', '1966', '1965', '1964', '1963', '1962', '1961', '1960', '1959', '1958', '1957', '1956', '1955', '1954', '1953', '1952', '1951', '1950', '1949', '1948', '1947', '1946', '1945', '1944', '1943', '1942', '1941', '1940', '1939', '1938', '1937', '1936', '1935', '1934', '1933', '1932', '1931', '1930', '1929', '1928', '1927', '1926', '1925', '1924', '1923', '1922', '1921', '1920', '1919', '1918', '1917', '1916', '1915', '1914', '1913', '1912', '1911', '1910');

foreach($year as $yearsel) {
    if($_POST['Year'] == $yearsel) {
            $isselected = "selected";
    } else {
            $isselected = "";   
    }

echo "<option value='$yearsel' $isselected>$yearsel</option> 
";
}

echo "
";
?>

I've tried looking in to if, elseif, else statements. However, every time I try doing this, it gives the code an error saying I did something wrong. So I'm not sure where to go about with that.

echo "
";

I would like for the month, day, year to be dynamic and have the results as stated in the summary of the problem.

You can store the bits that are missing prior to building the message and then decide how many parts there are. If there are errors, if there is just one error - the first error is put out by itself, otherwise the errors are built up into a list with implode() and the last error removed with array_pop() and added with and in the text...

$errors = [];
if(($_POST['Month'] == "Month") && ($_SERVER['REQUEST_METHOD'] == 'POST')){
    $errors[] = "month";
}


if(($_POST['Day'] == "Day") && ($_SERVER['REQUEST_METHOD'] == 'POST')){
    $errors[] = "day";
}


if(($_POST['Year'] == "Year") && ($_SERVER['REQUEST_METHOD'] == 'POST')){
    $errors[] = "year";
}

if ( !empty ( $errors ) )   {
    $msg = "<strong>Please select a ";
    if ( count($errors) == 1 )  {
        $msg .= $errors[0];
    }
    else  {
        $lastError = array_pop($errors);
        $msg .= implode(", ", $errors). " and " .$lastError;
    }
    $msg .= "! &nbsp</strong>";
    echo $msg;
}