我有一张包含日期和星期几的表格,例如:2012-05-01、星期二 2012-05-02、星期三等。
我正在尝试将它显示在像表格这样的日历中。问题是它每天都在不同的行中显示它。
$date4 = date("Y-m-d");
$date3 = date('Y-m-d',strtotime('-1 second',strtotime('+1 month',strtotime(date('m').'/01/'.date('Y').' 00:00:00'))));
$sql3 = "SELECT * FROM trn_cal WHERE dat >= '$date4' AND dat <= '$date3'";
$res3 = mysql_query($sql3);
echo "<table width='700px' border='1'>";
echo " <tr>";
echo " <td width='100px'>Sunday</td>";
echo " <td width='100px'>Monday</td>";
echo " <td width='100px'>Tuesday</td>";
echo " <td width='100px'>Wednesday</td>";
echo " <td width='100px'>Thursday</td>";
echo " <td width='100px'>Friday</td>";
echo " <td width='100px'>Saturday</td>";
echo " </tr>";
echo "</table>";
echo "<table width='700px' border='1'>";
while ($row3 = mysql_fetch_assoc($res3)) {
$weekday = $row3['weekday'];
$weekdate = $row3['weekdate'];
echo " <tr>";
echo " <td width='100px'>";
if ($weekday == "Sunday") {
echo $weekdate;
}
echo "</td>";
echo " <td width='100px'>";
if ($weekday == "Monday") {
echo $weekdate;
}
echo "</td>";
echo " <td width='100px'>";
if ($weekday == "Tuesday") {
echo $weekdate;
}
echo "</td>";
echo " <td width='100px'>";
if ($weekday == "Wednesday") {
echo $weekdate;
}
echo "</td>";
echo " <td width='100px'>";
if ($weekday == "Thursday") {
echo $weekdate;
}
echo "</td>";
echo " <td width='100px'>";
if ($weekday == "Friday") {
echo $weekdate;
}
echo "</td>";
echo " <td width='100px'>";
if ($weekday == "Saturday") {
echo $weekdate;
}
echo "</td>";
echo " </tr>";
}
echo "</table>";