
04-21-09, 12:00 AM
|
 |
iNET Code Serf
|
|
Join Date: Aug 2007
Location: West Chester, OH, USA
Posts: 37
Thanks: 0
Thanked 1 Time in 1 Post
|
|
This might work, though I haven't actually tested it....
PHP Code:
function availableDates(&$DB, $personnelId, $month) {
// Base on the ID, check with the individual schedule
$queryID = "SELECT individual_schedule_date FROM dms_individual_schedule WHERE personnel_id = $personnelId";
$rsID = $DB->Execute($queryID);
$arrID = $rsID->FetchRow();
// Remove the last 2 character (, ) from the string using substr
// Use explode to convert string into array
$dates = explode(', ', substr($arrID['individual_schedule_date'], 0, -2));
// Get the available dates for the specified month instead of the whole schedule
$availableDates = array()
foreach ($dates as $dateValue) {
if (substr($dateValue, 5, 2) == $month) {
$availableDates[] = $dateValue;
}
}
return $availableDates;
}
$DB = NewADOConnection('mysql');
$DB->Connect(@$server, @$user, @$pwd, @$db);
$query = "SELECT id, personnel_name FROM dms_personnel";
$rs = $DB->Execute($query);
$arr = $rs->GetRows();
$count = count($arr) - 1;
$personnelDates = array();
for ($i = 0; $i <= $count; $i++) {
$personnelDates[$arr[$i]['personnel_name']] = availableDates($DB, $arr[$i]['id'], '04');
}
echo '<pre>'.print_r($personnelDates, 1).'</pre>';
|