我正在努力弄清楚如何entitlement
从 table1 中获取原始数字,然后从 table2 中的每个请求中减去“天”,以开始日期顺序。
第一张桌子得到他们的权利数字
第二个表获取请求
任何指导将不胜感激,我正在寻找的输出是:
Start Date End Date Days to be taken Days remaining
- - - 22
01 Sep 2011 03 Sep 2011 3 19
10 Sep 2011 11 Sep 2011 2 17
这是我的代码:
$is_business_result = mysql_query('SELECT * FROM holiday_entitlement_business_manual WHERE employee = \'' . $username . '\' AND academic_year = \'' . $acyear . '\' ');
if($is_business = mysql_fetch_array($is_business_result)) {
echo '<div style="float:left; width:400px;">';
echo '<table width="100%">
<tr>
<td><strong>Name:</strong></td>
<td>'.$is_business['employee'].'</td>
</tr>
<tr>
<td><strong>Entitlement:</strong></td>
<td>'.$is_business['entitlement'].' '.$is_business['units'].'</td>
</tr>
<tr>
<td><strong>Department / Division:</strong></td>
<td>'.$is_business['division'].'</td>
</tr>
<tr>
<td><strong>Line Manager:</strong></td>
<td>'.$is_business['line_manager'].'</td>
</tr>
</table>';
echo '<br/>';
echo '<br/>';
echo '<br/>';
echo '</div>';
echo '<table width="100%">
<tr>
<td><strong>Start Date</strong></td>
<td><strong>End Date</strong></td>
<td><strong>Days to be taken</strong></td>
<td><strong>Days remaining</strong></td>
</tr>';
echo '<tr>';
echo '<td>-</td>';
echo '<td>-</td>';
echo '<td>-</td>';
echo '<td>'.$is_business['entitlement'].'</td>';
echo '</tr>';
}
$requests_result = mysql_query('SELECT * FROM requests WHERE employee = \'' . $username . '\' AND approved = 1 AND academic_year = \'' . $acyear . '\' ORDER BY start_date ASC');
while($requests = mysql_fetch_array($requests_result)) {
$start_date = new DateTime($requests['start_date']);
$end_date = new DateTime($requests['end_date']);
$timestamp_start_date = $start_date->getTimestamp();
$timestamp_end_date = $end_date->getTimestamp();
$formatted_start_date = date("d M Y", $timestamp_start_date);
$formatted_end_date = date("d M Y", $timestamp_end_date);
echo '<tr>';
echo '<td>'.$formatted_start_date.'</td>';
echo '<td>'.$formatted_end_date.'</td>';
echo '<td>'.$requests['days'].'</td>';
echo '</tr>';
}
echo'</table>';
表格
CREATE TABLE IF NOT EXISTS `requests` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`academic_year` varchar(255) NOT NULL,
`employee` varchar(255) NOT NULL,
`start_date` varchar(255) NOT NULL,
`end_date` varchar(255) NOT NULL,
`days` varchar(255) NOT NULL,
`user` int(20) NOT NULL,
`approved` int(11) NOT NULL,
PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1 AUTO_INCREMENT=4 ;
CREATE TABLE IF NOT EXISTS `holiday_entitlement_business_manual` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`academic_year` varchar(255) NOT NULL,
`employee` varchar(255) NOT NULL,
`full_part_time` varchar(255) NOT NULL,
`weekly_hours` varchar(255) NOT NULL,
`division` varchar(255) NOT NULL,
`date_of_commencement` varchar(255) NOT NULL,
`entitlement` varchar(255) NOT NULL,
`units` varchar(255) NOT NULL,
`line_manager` varchar(255) NOT NULL,
`length_of_service` varchar(255) NOT NULL,
`band` varchar(255) NOT NULL,
`new_entitlement` varchar(255) NOT NULL,
`weekly_entitlement` varchar(255) NOT NULL,
PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1 AUTO_INCREMENT=227 ;