我遇到了一个无法找到解决方案的问题。我制定了一个时间表。 现在我想自动转到当天的数据。
现在当你看到它最初显示的星期一的时间表时,我希望它显示当天。
我如何轻松解决这个问题?
这是我的代码:
<?php
$dagvanweek = $arraydag[date("w")];
$dag = $_GET['dag'];
if ($dag!="maandag" && $dag!="dinsdag" && $dag!="woensdag" && $dag!="donderdag" && $dag!="vrijdag" && $dag!="zaterdag" && $dag!="zondag")
$huidigedag = date("l");
$arraydag = array(
"zondag",
"maandag",
"dinsdag",
"woensdag",
"donderdag",
"vrijdag",
"zaterdag"
);
$huidigedag = $arraydag[date("w")];
$header = "<hr />
Kies een dag:
<a href='?dag=maandag'>Maandag</a> |
<a href='?dag=dinsdag'>Dinsdag</a> |
<a href='?dag=woensdag'>Woensdag</a> |
<a href='?dag=donderdag>Donderdag</a> |
<a href='?dag=vrijdag'>Vrijdag</a> |
<a href='?dag=zaterdag'>Zaterdag</a> |
<a href='?dag=zondag'>Zondag</a>
<br />";
$get = mysqli_query($con, "SELECT count(*) AS num FROM event_rooster WHERE dag='$huidigedag' AND `naam`!=''");
if($get->num_rows == 0) {
echo 'Geen rijen';
}
else
{
echo "$header <p><table align='center' cellpadding='1' cellspacing='1' width='400' border='0' cellspacing='3' cellpadding='3'>
<tr>
<th>Naam</td>
<th>Evenement</td>
<th>Tijd</td>
</tr>";
$q1 = mysqli_query($con, "SELECT * FROM event_rooster WHERE `dag`='$dag' AND `naam`!='' ORDER BY `id` ASC ");
while($r=mysqli_fetch_assoc($q1))
{
}
echo "<tr>
<td>".stripslashes($r['event'])."</td>
<td>".stripslashes($r['omschrijving'])."</td>
<td>".stripslashes($r['tijd'])."</td>
</tr>";
}
echo "</table>";
}
?>
抱歉,这是用荷兰语写的。
Maandag = Monday
Dinsdag = Tuesday
Woensdag = Wednesday
Donderdag = Thursday
Vrijdag = Friday
Zaterdag = Saturday
Zondag = Sunday
答案 0 :(得分:0)
不清楚你想要什么,但猜测:
$dag = $_GET['dag'];
if(empty($dag)){
$dag=date("l"); //assumes you set location properly and day name is in dutch
}