如何在简单的php日历中创建事件?

如何在简单的php日历中创建事件?,php,html,mysql,calendar,Php,Html,Mysql,Calendar,你好,我已经浪费了几天的时间来制作一个有活动的日历,只是放弃了。 为了重新开始,我找到了有史以来最简单的日历生成器。 如何在此日历中制作活动 我想从数据库事件中获取信息。 如果那天有活动,我想让它在日期悬停时显示活动。 我想每天最多展示10个活动(不是所有的日子都有活动) 下面是一个简单的日历脚本 <?php /* Set the default timezone */ date_default_timezone_set("America/Montreal"); /* Set the d

你好,我已经浪费了几天的时间来制作一个有活动的日历,只是放弃了。 为了重新开始,我找到了有史以来最简单的日历生成器。 如何在此日历中制作活动

我想从数据库事件中获取信息。 如果那天有活动,我想让它在日期悬停时显示活动。 我想每天最多展示10个活动(不是所有的日子都有活动)

下面是一个简单的日历脚本

<?php
/* Set the default timezone */
date_default_timezone_set("America/Montreal");

/* Set the date */
$date = strtotime(date("Y-m-d"));

$day = date('d', $date);
$month = date('m', $date);
$year = date('Y', $date);
$firstDay = mktime(0,0,0,$month, 1, $year);
$title = strftime('%B', $firstDay);
$dayOfWeek = date('D', $firstDay);
$daysInMonth = cal_days_in_month(0, $month, $year);
/* Get the name of the week days */
$timestamp = strtotime('next Sunday');
$weekDays = array();
for ($i = 0; $i < 7; $i++) {
    $weekDays[] = strftime('%a', $timestamp);
    $timestamp = strtotime('+1 day', $timestamp);
}
$blank = date('w', strtotime("{$year}-{$month}-01"));
?>
<table class='table table-bordered' style="table-layout: fixed;">
    <tr>
        <th colspan="7" class="text-center"> <?php echo $title ?> <?php echo $year ?> </th>
    </tr>
    <tr>
        <?php foreach($weekDays as $key => $weekDay) : ?>
            <td class="text-center"><?php echo $weekDay ?></td>
        <?php endforeach ?>
    </tr>
    <tr>
        <?php for($i = 0; $i < $blank; $i++): ?>
            <td></td>
        <?php endfor; ?>
        <?php for($i = 1; $i <= $daysInMonth; $i++): ?>
            <?php if($day == $i): ?>
                <td><strong><?php echo $i ?></strong></td>
            <?php else: ?>
                <td><?php echo $i ?></td>
            <?php endif; ?>
            <?php if(($i + $blank) % 7 == 0): ?>
                </tr><tr>
            <?php endif; ?>
        <?php endfor; ?>
        <?php for($i = 0; ($i + $blank + $daysInMonth) % 7 != 0; $i++): ?>
            <td></td>
        <?php endfor; ?>
    </tr>
</table>



你的问题太广泛了。无论如何,试着用,