Php 表的回声不正确
我有一个表,可以为员工计算缺勤天数,它工作得很好,但是当我尝试在表的末尾添加一个总计行,以获得每个列的总和时。一切都错了。我做错了什么 代码:Php 表的回声不正确,php,Php,我有一个表,可以为员工计算缺勤天数,它工作得很好,但是当我尝试在表的末尾添加一个总计行,以获得每个列的总和时。一切都错了。我做错了什么 代码: 周休假月br年休假月br病假日休日婚假母亲休假有理由缺席无理由年假剩余扣除后的年假剩余 '; $WeeklyVacationCount=0; $YearlyVacationCount=0; $SickDayCount=0; $HolidayCount=0; $MarriageLeaveCount=0; $MotherhoodVacationCount=
周休假月br年休假月br病假日休日婚假母亲休假有理由缺席无理由年假剩余扣除后的年假剩余
';
$WeeklyVacationCount=0;
$YearlyVacationCount=0;
$SickDayCount=0;
$HolidayCount=0;
$MarriageLeaveCount=0;
$MotherhoodVacationCount=0;
$AbsenceWithReasonCount=0;
$AbsenceWithoutReasonCount=0;
对于($i=1;$i),这是因为您没有对变量值使用串联运算符
您的代码:
echo "<td>$WeeklyVacationCount</td>";
echo“$WeeklyVacationCount”;
代码应为:
echo "<td>".$WeeklyVacationCount."</td>";
echo“$WeeklyVacationCount.”;
将循环更改为此
for($i=1;$i<=12;$i++){
echo '<tr>
<th style="text-align:left;">'.date('F', mktime(0, 0, 0, $i, 10)).'</th>
<td>'.getCount($afnbr,$year,$i,'WeeklyVacation').'</td>';
$WeeklyVacationCount+=$WeeklyVacation;
echo "<td>{$WeeklyVacation}</td>";
echo '<td>'.getCount($afnbr,$year,$i,'YearlyVacation').'</td>';
$YearlyVacationCount+=$YearlyVacation;
echo "<td>{$YearlyVacation}</td>";
echo '<td>'.getCount($afnbr,$year,$i,'SickDay').'</td>';
$SickDayCount+=$SickDay;
echo "<td>{$SickDay}</td>";
echo '<td>'.getCount($afnbr,$year,$i,'Holiday').'</td>';
$HolidayCount+=$Holiday;
echo "<td>{$Holiday}</td>";
echo '<td>'.getCount($afnbr,$year,$i,'MarriageLeave').'</td>';
$MarriageLeaveCount+=$MarriageLeave;
echo "<td>{$MarriageLeave}</td>";
echo '<td>'.getCount($afnbr,$year,$i,'MotherhoodVacation').'</td>';
$MotherhoodVacationCount+=$MotherhoodVacation;
echo "<td>{$MotherhoodVacation}</td>";
echo '<td>'.getCount($afnbr,$year,$i,'AbsenceWithReason').'</td>';
$AbsenceWithReasonCount+=$AbsenceWithReason;
echo "<td>{$AbsenceWithReason}</td>";
echo '<td>'.getCount($afnbr,$year,$i,'AbsenceWithoutReason').'</td>';
$AbsenceWithoutReasonCount+=$AbsenceWithoutReason;
echo "<td>{$AbsenceWithoutReason}</td>";
echo '<td>'.(15 - getCount($afnbr,$year,$i,'YearlyVacation')).'</td>';
echo '<td>'.getCount($afnbr,$year,$i,'DeductedVacation').'</td>';
echo '<td>'.(15 - getCount($afnbr,$year,$i,'YearlyVacation') - getCount($afnbr,$year,$i,'DeductedVacation')).'</td>';
echo '</tr>';
}
for($i=1;$i您的代码充满了错误
echo '<tr>
<th style="text-align:left;">'.date('F', mktime(0, 0, 0, $i, 10)).'</th>
<td>'.getCount($afnbr,$year,$i,'WeeklyVacation').'</td>
$WeeklyVacationCount+=$WeeklyVacation;
echo "<td>{$WeeklyVacation}</td>";
echo'
“.date('F',mktime(0,0,0,$i,10))。”
“.getCount($afnbr,$year,$i,'WeeklyVacation')”
$WeeklyVacationCount+=$WeeklyVacation;
回声“{$WeeklyVacation}”;
真是一团糟
<tr>
<th style="text-align:left;" >
<?php echo date('F', mktime(0, 0, 0, $i, 10)); ?>
</th>
<td>
<?php echo getCount($afnbr,$year,$i,'WeeklyVacation'); ?>
</td>
<?php $WeeklyVacationCount += $WeeklyVacation; ?>
<td>
<?php echo $WeeklyVacation; ?>
</td>
</tr>
您是否正确调整了音响效果?op正在部分使用它。:)我有未定义的变量,比如$weeklyvacation和我得到的所有其他值。我并不失望,你应该选择一种引用样式并坚持使用它。看看用一些格式读起来有多容易。当它如此混乱时,几乎不可能看到发生了什么。它的大部分只是缺少
或”
或其他l用“
换”
之类的小东西。我建议你找一个模板引擎,它们不难设置,而且可以省去很多麻烦。另外,所有酷孩子都会使用它们。
<tr>
<th style="text-align:left;" >
<?php echo date('F', mktime(0, 0, 0, $i, 10)); ?>
</th>
<td>
<?php echo getCount($afnbr,$year,$i,'WeeklyVacation'); ?>
</td>
<?php $WeeklyVacationCount += $WeeklyVacation; ?>
<td>
<?php echo $WeeklyVacation; ?>
</td>
</tr>