I have put this PHP event calendar on my development system. How can I disable adding event on a Saturday or a Sunday? :) Do you think this has to do with this code?
function dayPullDown($day)
{
echo "<select name=\"day\">
";
$selected[$day] = ' selected="selected"';
for($i=1;$i <= 31; $i++) {
$sel = (isset($selected[$i])) ? $selected[$i] : "";
echo " <option value=\"$i\"$sel>$i</option>
";
}
echo "</select>
";}
Instead of looping through 31 days, you could use PHP's datetime
class and check if today is a weekday (not a weekend) and display the dropdown menu only if your condition is satisfied:
$date = new DateTime();
if($date->format('N') < 6) {
echo "<select name=\"day\">
";
$sel = (isset($selected[$i])) ? $selected[$i] : "";
echo " <option value=\"$i\"$sel>$i</option>
";
echo "</select>
";
}