【发布时间】:2021-07-03 12:16:10
【问题描述】:
我想制作一个考勤列表,其中输入表单中输入的日期放在右侧第 3 列的标题中。在以下列的标题中,此日期增加了 7 天。
我有三个问题:
- 为什么标题中没有填写日期?
- 如何在if语句中插入html表格?
- 如何使日期列的宽度变大 1 个字符?
我创建了一个输入表单forum.php 和一个动作脚本gen-table.php。
输入表单forum.php:
<!DOCTYPE html>
<html>
<style>
td, th {
border: 4px solid lightblue;
text-align: left;
padding: px;
}
</style>
<h2> ATTENDANCE LIST </h2>
</head>
<body>
<form action="gen-table.php" method="post">
<p>
<label for="startdate">Startdate:</label>
<input type="date" name="startdate" id="startdate" />
<input type="submit" value="Select and Activate" />
</p>
</body>
</html>
动作脚本gen-table.php:
<!DOCTYPE html>
<html>
<style>
td, th {
border: 4px solid lightblue;
text-align: left;
padding: px;
}
</style>
<h2> ATTENDANCE LIST </h2>
</head>
<?php
if (isset($_POST[startdate])) {
$day1 = date('d-m-Y',strtotime(startdate ."+0 Days"));
$day2 = date('d-m-Y',strtotime(startdate ."+7 Days"));
$day3 = date('d-m-Y',strtotime(startdate ."+14 Days"));
$day4 = date('d-m-Y',strtotime(startdate ."+21 Days"));
}
else
{
echo "Select startdate";
}
?>
<table>
<th>Lastname</th>
<th>Firstname</th>
<td><?php print $day1 ?> </td><td><?php echo $day2 ?></td><td><?php echo $day3 ?> </td><td><?php echo $day4 ?> </td>
</table>
</html>
【问题讨论】:
-
您在浏览器查看此页面的源代码功能中看到了什么?