objectevent.php 1.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647
  1. <?php
  2. include "auth.php";
  3. if(isset($_POST['calendar'])&& isset($_POST['machine'])){
  4. $machineid = htmlentities(mysqli_real_escape_string($link, $_POST['machine']));
  5. $calendar=htmlentities(mysqli_real_escape_string($link,$_POST['calendar']));
  6. if (isset($_POST['dateadd'])) {
  7. if($_POST['dateevent']!=null)
  8. $msg = htmlentities(mysqli_real_escape_string($link, $_POST['dateevent']));
  9. else
  10. $msg = 'Событие';
  11. $query = "INSERT INTO object_event VALUES (NULL,'$calendar','$msg','$machineid')";
  12. $result = mysqli_query($link, $query) or die("Ошибка " . mysqli_error($link));
  13. if($result)
  14. echo "Добавлено событие";
  15. }
  16. if (isset ($_POST['dateget']) && $calendar!=null) {
  17. echo "<b>Результат по дате</b>";
  18. echo "<br>";
  19. $query = "SELECT * FROM object_event
  20. WHERE date_event='$calendar' AND id_object='$machineid' ORDER BY id DESC";
  21. $result = mysqli_query($link, $query) or die("Ошибка " . mysqli_error($link));
  22. while ($res = mysqli_fetch_array($result)) {
  23. echo $res['date_event']." ".$res['event'];
  24. echo "<br>";
  25. }
  26. }
  27. if (isset ($_POST['dateget']) && $calendar==null) {
  28. echo "<br>";
  29. echo "<b>Результат по объекту</b>";
  30. echo "<br>";
  31. $query = "SELECT * FROM object_event
  32. WHERE id_object='$machineid' ORDER BY id DESC ";
  33. $result = mysqli_query($link, $query) or die("Ошибка " . mysqli_error($link));
  34. while ($res = mysqli_fetch_array($result)) {
  35. echo $res['date_event']." ".$res['event'];
  36. echo "<br>";
  37. }
  38. }
  39. }