duankange2433 2016-09-17 18:23
浏览 279
已采纳

仅查看当前月份的FullCalendar

Good afternoon friends, how do I display only the names of the events by the month, not the year as shown in the code below. Example, has 04 user in month 09.

<?php

//Database
$data = array();


$link = mysqli_connect("localhost", "root", "", "agenda");

mysqli_set_charset($link, 'utf8');

if (!$link) {
    echo "Error: Unable to connect to MySQL." . PHP_EOL;
    echo "Debugging errno: " . mysqli_connect_errno() . PHP_EOL;
    echo "Debugging error: " . mysqli_connect_error() . PHP_EOL;
    exit;
}

$query = "SELECT * FROM clientes";

if ($result = $link->query($query)) {

    /* fetch object array */
    while ($obj = $result->fetch_object()) {
        $data[] = array(
            'id' => $obj->id,
            'title'=> $obj->title,
            'start'=> $obj->start
        );
    }

    /* free result set */
    $result->close();
}

mysqli_close($link);

?>

<script>

    $(document).ready(function() {

        $('#clientes').fullCalendar({
            header: {
                left: 'prev,next today',
                center: 'title',
                right: 'month,basicWeek,basicDay'
            },
            defaultDate: '<?php echo date('Y-m-d');?>',
            editable: true,
            eventLimit: true, // allow "more" link when too many events
            events : <?php echo json_encode($data);?>
        });

    });

</script>

Sample output

Database schema

This is the code of the second block of the same result.

<?php

//Database
$data = array();

$link = mysqli_connect("localhost", "root", "", "agenda");

mysqli_set_charset($link, 'utf8');

$month = date('n');
$year = date('Y');
$query = "SELECT * FROM clientes WHERE MONTH(`start`) = $month AND YEAR(`start`) = $year";


if ($result = $link->query($query)) {

    /* fetch object array */
    while ($obj = $result->fetch_object()) {
        $data[] = array(
            'id' => $obj->id,
            'title'=> $obj->title,
            'start'=> $obj->start
        );
    }

    /* free result set */
    $result->close();
}

mysqli_close($link);

?>

enter image description here

If the code is so, he warns "Invalid Data":

$month = date('n');
$year = date('Y');
if (is_int($month) && is_int($year)) {
    $query = "SELECT * FROM clientes WHERE MONTH(`start`) = $month AND YEAR(`start`) = $year";
} else {
    die ('Invalid data');
}
  • 写回答

2条回答 默认 最新

  • dsceme82487 2016-09-19 19:13
    关注

    I got the Problem Making Next make way.

    Placing the select as follows.

    $query = "select id, title,  concat_ws( '-', year(now()), MONTH(start), DAY(start)) AS start from clientes";
    
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(1条)

报告相同问题?

悬赏问题

  • ¥15 C++ 头文件/宏冲突问题解决
  • ¥15 用comsol模拟大气湍流通过底部加热(温度不同)的腔体
  • ¥50 安卓adb backup备份子用户应用数据失败
  • ¥20 有人能用聚类分析帮我分析一下文本内容嘛
  • ¥15 请问Lammps做复合材料拉伸模拟,应力应变曲线问题
  • ¥30 python代码,帮调试
  • ¥15 #MATLAB仿真#车辆换道路径规划
  • ¥15 java 操作 elasticsearch 8.1 实现 索引的重建
  • ¥15 数据可视化Python
  • ¥15 要给毕业设计添加扫码登录的功能!!有偿