Parcourir la source

课程表从数据库读取数据

visuddhinanda il y a 5 ans
Parent
commit
e9e5c9f026

+ 49 - 0
app/lib/fullcalendar/examples/php/get_date.php

@@ -0,0 +1,49 @@
+<?php
+//
+
+require_once "../../../../path.php";
+require_once "../../../../public/_pdo.php";
+
+if(isset($_GET["teacher"])){
+    $teacher = " teacher = ? ";
+}
+else{
+    $teacher = " 1= 1";
+}
+
+global $PDO;
+PDO_Connect("sqlite:"._FILE_DB_COURSE_);
+
+$query = "select * from course where $teacher  order by create_time DESC limit 0,100";
+if(isset($_GET["teacher"])){
+	$Fetch = PDO_FetchAll($query,array($_GET["teacher"]));
+}
+else{
+	$Fetch = PDO_FetchAll($query);
+}
+
+$output = array();
+foreach ($Fetch as $key => $couse) {
+	# code...
+	$query = "select * from lesson where course_id = '{$couse["id"]}'   limit 0,300";
+	$fAllLesson = PDO_FetchAll($query);
+	foreach ($fAllLesson as  $lesson) {
+		# code...
+		#		"id": "999",
+		#"title": "Dhammacakkha",
+		#"url": "https://www.wikipali.org/app/course/lesson.php?id=6a42e993-8f7e-414a-a291-a4094764f992",
+		#"start": "2020-12-11T08:00:00+06:30",
+		#"end": "2020-12-11T09:30:00+06:30"
+		$start = date("Y-m-d\TH:i:s+00:00",$lesson["date"]/1000);
+		$end = date("Y-m-d\TH:i:s+00:00",$lesson["date"]/1000+$lesson["duration"]);
+		$output[]=array("id"=>$lesson["id"],
+									"title"=>$couse["title"],
+									"url"=>"../../../course/lesson.php?id=".$lesson["id"],
+									"start"=> $start,
+									"end"=>$end
+								);
+	}
+}
+echo json_encode($output, JSON_UNESCAPED_UNICODE);
+
+?>

+ 1 - 1
app/lib/fullcalendar/examples/time-zones.html → app/lib/fullcalendar/examples/time-zones.php

@@ -37,7 +37,7 @@
 					selectable: true,
 					dayMaxEvents: true, // allow "more" link when too many events
 					events: {
-						url: "php/get-events.php",
+						url: "php/get_date.php?teacher=<?php echo $_GET["teacher"]?>",
 						failure: function () {
 							document.getElementById("script-warning").style.display = "inline"; // show
 						},

+ 1 - 1
app/uhome/course.php

@@ -24,7 +24,7 @@ include "../pcdl/html_head.php";
     },
     function(data,status){
         let arrData = JSON.parse(data);
-        let html='<iframe style="width: 100%;height: 67em;" src="../lib/fullcalendar/examples/time-zones.html"></iframe>';
+        let html='<iframe style="width: 100%;height: 67em;" src="../lib/fullcalendar/examples/time-zones.php?teacher=<?php echo $_GET["userid"]; ?>"></iframe>';
         for (const iterator of arrData) {
             html += '<div class="card" style="display:flex;margin:1em;padding:10px;">';
 

+ 2 - 0
app/uhome/head.php

@@ -58,6 +58,8 @@
         </div>
 
         <div id="main_tag"  style="">
+            <span tag=<?php echo "jianjie";?>><?php echo "简介";?></span>
+
             <a href="trans.php?userid=<?php echo $_GET["userid"];?>">
                 <span tag=<?php echo $_local->gui->translation;?>>  
                     <?php echo $_local->gui->translation;?>