PHP,按月/月/年的月间隔从表中获取事件

时间:2015-09-29 11:13:22

标签: php mysql

你好我有一个函数来在月份间隔中获取事件,我在那里向函数发送日,月和年。我需要这个......当我发布一个函数时,日期为30.5.2015,数据库中的事件将于2015年4月31日发布,那么我需要在2015年5月30日那天显示事件。现在它适用于我每天看到的事件......功能看起来像吼叫......

function loadAllDayEventsIntervalMonthly($array) {
    global $db;

    $query = "SELECT * from `kalendar_user_events` where `interval`='3' and `uid`='" . $_SESSION['uid'] . "' and `allDay`='1'";
    foreach ($db->select($query) as $res) {

        $days = cal_days_in_month(CAL_GREGORIAN, $array->month, $array->year);
        $daysDb = cal_days_in_month(CAL_GREGORIAN, $res->month, $res->year);

        if ($array->day != $res->day) {
            if ($res->day > $days and $days > $daysDb) {
                echo "<input type='hidden' class='eachEventForDay' data-id='" . $res->id . "'
                 data-color='" . $res->color . "' data-name='" . $res->name . "' data-place='" . $res->place . "' 
                 data-interval='" . $res->interval . "' data-notification='" . $res->notification . "' 
                 data-day='" . $res->day . "' data-month='" . $res->month . "' data-year='" . $res->year . "' 
                 data-allDay='" . $res->allDay . "' data-time='" . $res->time . "' data-position='" . $res->position . "' 
                 data-dragable='yes' data-from='calendar' data-edit='full'>";
            }
        } else {
            echo "<input type='hidden' class='eachEventForDay' data-id='" . $res->id . "'
                 data-color='" . $res->color . "' data-name='" . $res->name . "' data-place='" . $res->place . "' 
                 data-interval='" . $res->interval . "' data-notification='" . $res->notification . "' 
                 data-day='" . $res->day . "' data-month='" . $res->month . "' data-year='" . $res->year . "' 
                 data-allDay='" . $res->allDay . "' data-time='" . $res->time . "' data-position='" . $res->position . "' 
                 data-dragable='yes' data-from='calendar' data-edit='full'>";
        }
    }
}

1 个答案:

答案 0 :(得分:0)

好的,我解决了......如果你感兴趣的话......有代码

function loadAllDayEventsIntervalMonthly($array){
        global $db;

        $query = "SELECT * from `kalendar_user_events` where `interval`='3' and `uid`='".$_SESSION['uid']."' and `allDay`='1'";
        foreach($db->select($query) as $res){

        $days = cal_days_in_month(CAL_GREGORIAN, $array->month, $array->year);
        $daysDb = cal_days_in_month(CAL_GREGORIAN, $res->month, $res->year);        


        if($array->day != $res->day){

                if($array->day < $days){

                }else{
                echo "<input type='hidden' class='eachEventForDay' data-id='".$res->id."'
                 data-color='".$res->color."' data-name='".$res->name."' data-place='".$res->place."' 
                 data-interval='".$res->interval."' data-notification='".$res->notification."' 
                 data-day='".$res->day."' data-month='".$res->month."' data-year='".$res->year."' 
                 data-allDay='".$res->allDay."' data-time='".$res->time."' data-position='".$res->position."' 
                 data-dragable='yes' data-from='calendar' data-edit='full'>";   
                }


        }else{
            echo "<input type='hidden' class='eachEventForDay' data-id='".$res->id."'
                 data-color='".$res->color."' data-name='".$res->name."' data-place='".$res->place."' 
                 data-interval='".$res->interval."' data-notification='".$res->notification."' 
                 data-day='".$res->day."' data-month='".$res->month."' data-year='".$res->year."' 
                 data-allDay='".$res->allDay."' data-time='".$res->time."' data-position='".$res->position."' 
                 data-dragable='yes' data-from='calendar' data-edit='full'>";   
        }


        }       



        }