嗨,我正在用php制作每周日历,我想像这样example在日历中放置事件,但是我不知道如何在一天的正确时间回显日历中的事件。
这是我用来回显日历的代码:
<?php
$dt = new DateTime;
if (isset($_GET['year']) && isset($_GET['week'])) {
$dt->setISODate($_GET['year'], $_GET['week']);
}else{
$dt->setISODate($dt->format('o'), $dt->format('W'));
}
$year = $dt->format('o');
$week = $dt->format('W');
?>
<a href="<?php echo $_SERVER['PHP_SELF'].'?week='.($week-1).'&year='.$year; ?>">Vorige week</a>
<a href="<?php echo $_SERVER['PHP_SELF'].'?week='.($week+1).'&year='.$year; ?>">Volgende week</a>
<?php
$getDatum = $conn->prepare("
SELECT DISTINCT D.DocentID, CONCAT(D.Voornaam, ' ', D.Achternaam) AS Docentnaam, D.Telefoonnummer, D.Mobiel, D.Email, CO.DatumBegin, CO.DatumEind, O.Onderdeelnaam
FROM docenten D
INNER JOIN psentity PE ON D.DocentID = PE.psid
INNER JOIN docentonderdelen DO ON D.DocentID = DO.DocentID
INNER JOIN cursusonderdelen CO ON DO.OnderdeelID = CO.OnderdeelID
RIGHT JOIN onderdelen O ON CO.OnderdeelID = O.OnderdeelID
WHERE O.OnderdeelID = 6
AND CO.DatumBegin AND CO.DatumEind BETWEEN '2018-12-10' AND '2019-10-10'
AND PE.deleted = 0
LIMIT 3");
$getDatum->bindParam(':OID', $OID, PDO::PARAM_STR);
$getDatum->bindParam(':BeginDatum', $BeginDatum, PDO::PARAM_STR);
$getDatum->bindParam(':Einddatum', $Einddatum, PDO::PARAM_STR);
$getDatum->execute();
$docenten = array();
while ($row = $getDatum->fetch(PDO::FETCH_ASSOC))
{
$docenten[] = $row;
}
Pastebin link to code 因为否则代码会很长。我希望我提供的信息足够。
答案 0 :(得分:0)
您可以将事件的时间存储在DatumBegin或新列中(假设eventTime的格式为<form>
<div></div>
<div class="item list"> 1 </div> | <div class="item list"> 4 </div>
<div class="item list"> 2 </div> | <div class="item list"> 5 </div>
<div class="item list"> 3 </div> | <div class="item list"> 6 </div>
<div> </div>
</form>
),并根据时间创建三个数组,然后在不同的(H:i:s)
中对其进行迭代
tr