helloxielan 2015-05-03 13:31 采纳率: 0%
浏览 88

如何将存储在数据库中的事件显示在日历中?

如何将存储在数据库中的事件显示在日历中?我不知道如何用自己的日期替换随机日期.....是不是必须遍历数据库获得的数据?并把数据修改为JSON格式?我可以用前轮吗?

这是zabuto日历下载网站提供的代码:

<?php include_once 'includes/sessions.php'; ?>
<?php include_once 'includes/connect.php';
/**
 * Example of JSON data for calendar
*
* @package zabuto_calendar
*/


if (!empty($_REQUEST['year']) && !empty($_REQUEST['month'])) {
$year = intval($_REQUEST['year']);
$month = intval($_REQUEST['month']);
$lastday = intval(strftime('%d', mktime(0, 0, 0, ($month == 12 ? 1 : $month + 1), 0, ($month == 12 ? $year + 1 : $year))));


$dates = array();
for ($i = 0; $i <= (rand(4, 10)); $i++) {
    $date = $year . '-' . str_pad($month, 2, '0', STR_PAD_LEFT) . '-' . str_pad(rand(1, $lastday), 2, '0', STR_PAD_LEFT);

$dates[$i] = array(
        'date' => $date,
        'badge' => ($i & 1) ? true : false,
        'title' => 'Example for ' . $date,
        'body' => '<p class="lead">Information for this date</p><p>You can add <strong>html</strong> in this block</p>',
        'footer' => 'Extra information',
    );

    if (!empty($_REQUEST['grade'])) {
        $dates[$i]['badge'] = false;
        $dates[$i]['classname'] = 'grade-' . rand(1, 4);
    }

    if (!empty($_REQUEST['action'])) {
        $dates[$i]['title'] = 'Action for ' . $date;
        $dates[$i]['body'] = '<p>The footer of this modal window consists of two buttons. One button to close the modal window without further action.</p>';
        $dates[$i]['body'] .= '<p>The other button [Go ahead!] fires myFunction(). The content for the footer was obtained with the AJAX request.</p>';
        $dates[$i]['body'] .= '<p>The ID needed for the function can be retrieved with jQuery: <code>dateId = $(this).closest(\'.modal\').attr(\'dateId\');</code></p>';
        $dates[$i]['body'] .= '<p>The second argument is true in this case, so the function can handle closing the modal window: <code>myFunction(dateId, true);</code></p>';
        $dates[$i]['footer'] = '
        <button type="button" class="btn btn-default" data-dismiss="modal">Close</button>
        <button type="button" class="btn btn-primary" onclick="dateId = $(this).closest(\'.modal\').attr(\'dateId\'); myDateFunction(dateId, true);">Go ahead!</button>
        ';
    }
}

echo json_encode($dates);

} else {
echo json_encode(array());
}
  • 写回答

0条回答 默认 最新

    报告相同问题?

    悬赏问题

    • ¥15 从键盘输入不管多少字符或者数组 输出的时候先提示输出再显示结果 输出的时候字符间间隔一个空格符
    • ¥30 频率分析法分析绘制奈奎斯特图、波特图
    • ¥15 弹出来一万个系统找不到指定的文件框框,怎么解决
    • ¥15 ADS生成的微带线为什么是蓝色空心的
    • ¥15 求一下解题思路,完全不懂
    • ¥15 tensorflow
    • ¥15 densenet网络结构中,特征以cat方式复用后是怎么进行误差回传的
    • ¥15 STM32G471芯片spi设置了8位,总是发送16位
    • ¥15 R语言并行计算beta-NTI中tree文件的类型
    • ¥15 如何解读marsbar导出的ROI数据?