1 回答
TA贡献1851条经验 获得超3个赞
有一些明显的逻辑问题,但与 fullCalendar 没有太大关系:
1)我在之前的问题中多次提到过这一点:return
当您不在函数内部时不返回值。您认为您到底要把它返回到哪里?require
没有办法
2)即使有效,您也永远不会返回任何事件,因为您的while
循环已关闭并且不执行任何操作。
3)$result
无论如何都会超出 while 循环之外的范围。
4)你从不执行你的查询
5) 你没有知道echo
活动名称。
您需要将所有数据库结果放入一个数组中,然后循环该数组以生成与fc-event
数组中的条目一样多的 div。
这是一种方法 - 我将draggableevents.php 的功能放入一个函数中,您可以在需要时调用它。
拖拽事件.php
<?php
require "connection.php";
function getDraggableEvents() {
$conn = DB::databaseConnection();
$sql = "Select * FROM DraggableEvents";
$stmt = $conn->prepare($sql);
$stmt->execute();
$results = array();
while($row = $stmt->fetch(PDO::FETCH_ASSOC)) {
$results[] = $row;
}
return $results;
}
?>
表单.php
<html>
<head>
<link href='https://unpkg.com/@fullcalendar/core@4.4.0/main.min.css' rel='stylesheet' />
<link href='https://unpkg.com/@fullcalendar/daygrid@4.4.0/main.min.css' rel='stylesheet' />
<link href='https://unpkg.com/@fullcalendar/timegrid@4.4.0/main.min.css' rel='stylesheet' />
<script src='https://unpkg.com/@fullcalendar/core@4.4.0/main.min.js'></script>
<script src='https://unpkg.com/@fullcalendar/interaction@4.4.0/main.min.js'></script>
<script src='https://unpkg.com/@fullcalendar/daygrid@4.4.0/main.min.js'></script>
<script src='https://unpkg.com/@fullcalendar/timegrid@4.4.0/main.min.js'></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/moment.js/2.18.1/moment.min.js"></script>
<link href='https://unpkg.com/@fullcalendar/timeline@4.4.0/main.min.css' rel='stylesheet' />
<link href='https://unpkg.com/@fullcalendar/resource-timeline@4.4.0/main.min.css' rel='stylesheet' />
<script src='https://unpkg.com/@fullcalendar/timeline@4.4.0/main.min.js'></script>
<script src='https://unpkg.com/@fullcalendar/resource-common@4.4.0/main.min.js'></script>
<script src='https://unpkg.com/@fullcalendar/resource-timeline@4.4.0/main.min.js'></script>
<link rel="stylesheet" href="css/main.css" media="all">
<link href="main.css" rel="stylesheet">
<script src='main.js'></script>
</head>
<body>
<div id='external-events'>
<p>
<strong>Draggable Events</strong>
</p>
<?php
require 'draggableevents.php';
$events = getDraggableEvents();
foreach ($events as $event)
{
?>
<div class='fc-event'><?php echo $event['EventName']; ?></div>
<?php
}
?>
<p>
<input type='checkbox' id='drop-remove' />
<label for='drop-remove'>remove after drop</label>
</p>
</div>
<div id='calendar-container'>
<div id='calendar'></div>
</div>
</body>
</html>
- 1 回答
- 0 关注
- 94 浏览
添加回答
举报