my_lesson_update.php 1.3 KB

12345678910111213141516171819202122232425262728293031323334
  1. <?php
  2. require_once "../path.php";
  3. require_once "../public/_pdo.php";
  4. require_once '../public/function.php';
  5. global $PDO;
  6. PDO_Connect("sqlite:"._FILE_DB_COURSE_);
  7. $query="UPDATE lesson SET title = ? , subtitle = ? , date = ? , duration = ? , live = ? , replay = ? , summary = ? , teacher = ? , receive_time= ? , modify_time= ? where id = ? ";
  8. $sth = $PDO->prepare($query);
  9. $data = strtotime($_POST["lesson_date"]);
  10. $time = strtotime($_POST["lesson_time"]) - strtotime("today");
  11. $datatime = ($data+$time)*1000;
  12. $duration = strtotime($_POST["duration"]) - strtotime("today");
  13. $sth->execute(array($_POST["title"] , $_POST["subtitle"] ,$datatime, $duration , $_POST["live"] , $_POST["replay"] , $_POST["summary"] , $_POST["teacher"] , mTime() , mTime() , $_POST["lesson"]));
  14. $respond=array("status"=>0,"message"=>"");
  15. if (!$sth || ($sth && $sth->errorCode() != 0)) {
  16. $error = PDO_ErrorInfo();
  17. $respond['status']=1;
  18. $respond['message']=$error[2];
  19. echo "<div style=''>Lesson 数据修改失败:{$error[2]}</div>";
  20. }
  21. else{
  22. $respond['status']=0;
  23. $respond['message']="成功";
  24. echo "<div style=''>Lesson 数据修改成功</div>";
  25. echo $d=strtotime("today");
  26. echo strtotime($_POST["lesson_date"])."<br>";
  27. echo strtotime($_POST["lesson_time"])."<br>";
  28. echo (strtotime($_POST["duration"]) - $d)."<br>";
  29. }
  30. //echo json_encode($respond, JSON_UNESCAPED_UNICODE);
  31. ?>