Fullcalendar.События в базе данных не отображаются в календаре - PullRequest
0 голосов
/ 13 октября 2018

Я создал экземпляр Fullcalendar, работающий из базы данных.Все работает отлично, кроме событий в понедельник и четверг, которые появляются в базе данных, но не в календаре.Все дни недели обрабатываются одинаково в коде.Как это может случиться?Я приложил представления базы данных и календаря.Я также включил insert.php, где, как мне кажется, проблема заключается в

Просмотр календаря Просмотр базы данных

<html>
<body>

<?php
error_reporting(E_ERROR);
ini_set('display_errors', 1);
error_reporting(1);
$con = mysql_connect("127.0.0.1","neil","souhami2");

if (!$con) {
  die('Could not connect: ' . mysql_error());
}
mysql_select_db("fullcalendar", $con);
$date = ($_POST['dowstart']);
$date1 = str_replace('-', '/', $date);
$date = date('Y-m-d',strtotime($date1 . "-1 days"));
$date3 = ($_POST['dowend']);
$date4 = str_replace('-', '/', $date3);
$date2 = date('Y-m-d',strtotime($date4 . "+1 days"));
$error_message = "";


$titleErr = $equalErr = "";
$title = $start = $end = "";

if ($_SERVER["REQUEST_METHOD"] == "POST") {
  $title = test_input($_POST["title"]);
  $start = test_input($_POST["start"]);
  $end = test_input($_POST["end"]);
  $dow = test_input($_POST["dow"]);
  $color = test_input($_POST["color"]);
}

function test_input($data) {
  $data = trim($data);
  $data = stripslashes($data);
  $data = htmlspecialchars($data);
  return $data;
};

$one = $_POST["dow"][0];
$two = $_POST["dow"][1];
$three = $_POST["dow"][2];
$comma = $_POST["dow"][3];
$four = $_POST["dow"][4];
$five = $_POST["dow"][5];
$six = $_POST["dow"][6];
$comma = $_POST["dow"][7];
$eight = $_POST["dow"][8];
$nine = $_POST["dow"][9];
$ten = $_POST["dow"][10];
 $age=array("Mon"=>"1","Tue"=>"2","Wed"=>"3","Thu"=>"4","Fri"=>"5","Sat"=>"6","Sun"=>"0");


if($eight){
   $first = $one.$two.$three;
   $first = $age[$first];
   $second = $four.$five.$six;
   $second = $age[$second];
   $third = $eight.$nine.$ten;
   $third = $age[$third];
   $third = $first.$comma.$second.$comma.$third;
   $_POST["dow"] = $third;
}
else if($four){
   $first = $one.$two.$three;
   $first = $age[$first];
   $second = $four.$five.$six;
   $second = $age[$second];
   $second = $first.$comma.$second;
   $_POST["dow"] = $second;
}
else if($one){
   $first = $one.$two.$three;
   echo $one;echo $two;echo $three;
   $first = $age[$first];
   echo $first;
   $_POST["dow"] = $first;
};

$sql="INSERT INTO events (title, start, end, dow, dowstart, dowend, color)
      VALUES
  ('$_POST[title]','$_POST[start]','$_POST[end]','$_POST[dow]','$date','$date2','$_POST[color]')";



if (!mysql_query($sql,$con)) {
  die('Error: ' . mysql_error());
}

echo "1 record added";

header("location: index.html"); 

mysql_close($con)
?>
</body>
</html>

Этоprocess.php, который извлекает события:

<?php
include('config.php');

{
    $events = array();
    $query = mysqli_query($con, "SELECT * FROM events");
    while($fetch = mysqli_fetch_array($query,MYSQLI_ASSOC))
    {
        $e = array();
        $e['id'] = $fetch['id'];    
        $e['start'] = $fetch['start'];
        $e['end'] = $fetch['end'];
        $e['title'] = $fetch['title'];
        $e['dow'] = $fetch['dow'];
        $e['ranges'] = [ array("dowstart" => $fetch['dowstart'],"dowend" => $fetch['dowend'])];
        $e['color'] = $fetch['color'];

        array_push($events, $e);
    }
    echo json_encode($events);
}
?>

Это соответствующий раздел index.html

    $('#calendar').fullCalendar({
        events: JSON.parse(json_events),
        utc: true,
        header: {
            left: 'prev,next today',
            center: 'title',
            right: 'month,agendaWeek,agendaDay'
        },
        editable: true,
                    selectable: true,
                    select: function() {window.location.href = "http://www.villagehall.westerdale.info/booking/"},
        droppable: true, 
        slotDuration: '00:30:00',
                    eventRender: function(event){
                         return (event.ranges.filter(function(pixies){ 
                         return (event.start.isBefore(pixies.dowend) &&
                       event.end.isAfter(pixies.dowstart));

                    }).length)>0;
                    },
        eventReceive: function(event){
            var title = event.title;
            var start = event.start.format("YYYY-MM-DD[T]HH:mm:SS");
            $.ajax({
                url: 'process.php',
                data: 'type=new&title='+title+'&startdate='+start+'&enddate='+end+'&zone='+zone,
                type: 'POST',
                dataType: 'json',
                success: function(response){
                    event.id = response.eventid;
                    $('#calendar').fullCalendar('updateEvent',event);
                },
                error: function(e){
                    console.log(e.responseText);

                }
            });
            $('#calendar').fullCalendar('updateEvent',event);
            console.log(event);
        },
Добро пожаловать на сайт PullRequest, где вы можете задавать вопросы и получать ответы от других членов сообщества.
...