I have made a vacation planner to track employee vacations. But I want to add a feature to show conflicts. That is, only 1 person from each department can take vacation on a particular day. And I want a report for the month when vacations conflict. I cant seem to wrap my head around what to call, the day or the name. So I started with this

PHP Code:
<?php
$sqla
="SELECT DISTINCT(name) AS name, day AS day FROM forms_calendar WHERE month='$month' AND year='$year' ";
$resulta mysql_query($sqla) or die(("Error: ".mysql_error().$sqla));
while (
$rows=mysql_fetch_array($resulta)) {
$day=$rows['day'];
$name=$rows['name'];
$date "$month-$day-$year";

foreach (
$department as $value) {

//check for more than one name on that day in a particular department and show that name

echo '<p>'.$name.' ~ '.$date.'</p>';
}
}
?>
//check for more than one name on that day in a particular department and show that name
this is the part i dont get - or it maybe that I have set the select wrong in the first place.

Any help or ideas would be appreciated.