1234567891011121314151617181920212223242526272829303132333435363738394041424344454647 |
- <?php
- include "auth.php";
- if(isset($_POST['calendar'])&& isset($_POST['machine'])){
- $machineid = htmlentities(mysqli_real_escape_string($link, $_POST['machine']));
- $calendar=htmlentities(mysqli_real_escape_string($link,$_POST['calendar']));
- if (isset($_POST['dateadd'])) {
- if($_POST['dateevent']!=null)
- $msg = htmlentities(mysqli_real_escape_string($link, $_POST['dateevent']));
- else
- $msg = 'Событие';
- $query = "INSERT INTO object_event VALUES (NULL,'$calendar','$msg','$machineid')";
- $result = mysqli_query($link, $query) or die("Ошибка " . mysqli_error($link));
- if($result)
- echo "Добавлено событие";
- }
- if (isset ($_POST['dateget']) && $calendar!=null) {
- echo "<b>Результат по дате</b>";
- echo "<br>";
- $query = "SELECT * FROM object_event
- WHERE date_event='$calendar' AND id_object='$machineid' ORDER BY id DESC";
- $result = mysqli_query($link, $query) or die("Ошибка " . mysqli_error($link));
- while ($res = mysqli_fetch_array($result)) {
- echo $res['date_event']." ".$res['event'];
- echo "<br>";
- }
- }
- if (isset ($_POST['dateget']) && $calendar==null) {
- echo "<br>";
- echo "<b>Результат по объекту</b>";
- echo "<br>";
- $query = "SELECT * FROM object_event
- WHERE id_object='$machineid' ORDER BY id DESC ";
- $result = mysqli_query($link, $query) or die("Ошибка " . mysqli_error($link));
- while ($res = mysqli_fetch_array($result)) {
- echo $res['date_event']." ".$res['event'];
- echo "<br>";
- }
- }
- }
|