88 lines
2.1 KiB
PHP
88 lines
2.1 KiB
PHP
|
<?php header('Access-Control-Allow-Origin: *'); ?>
|
||
|
<!DOCTYPE html>
|
||
|
<html>
|
||
|
<head>
|
||
|
<style>
|
||
|
table {
|
||
|
<body style="background-color:powderblue;">
|
||
|
|
||
|
width: 100%;
|
||
|
border-collapse: collapse;
|
||
|
}
|
||
|
|
||
|
table, td, th {
|
||
|
border: 1px solid black;
|
||
|
padding: 5px;
|
||
|
color:white;
|
||
|
}
|
||
|
|
||
|
th {text-align: left;}
|
||
|
</style>
|
||
|
</head>
|
||
|
<body>
|
||
|
|
||
|
<?php
|
||
|
$q = intval($_GET['q']);
|
||
|
|
||
|
$con = mysqli_connect('mysql49.mydevil.net','m1344_dziennik','Julian2020!','m1344_dziennik');
|
||
|
if (!$con) {
|
||
|
die('Could not connect: ' . mysqli_error($con));
|
||
|
}
|
||
|
|
||
|
mysqli_select_db($con,"ajax_demo");
|
||
|
|
||
|
$sql = "SELECT h1.timestamp, l1.nameLesson as poniedzialek, l2.nameLesson as wtorek, l3.nameLesson as sroda, l4.nameLesson as czwartek, l5.nameLesson as piatek FROM hours as h1\n"
|
||
|
|
||
|
. "\n"
|
||
|
|
||
|
. "LEFT JOIN plan as p1 ON p1.id_day = 1 AND p1.id_hour = h1.id_hour AND p1.id_class = '".$q."'\n"
|
||
|
|
||
|
. "LEFT JOIN lessons AS l1 ON p1.id_lesson = l1.id_lesson\n"
|
||
|
|
||
|
. "LEFT JOIN plan as p2 ON p2.id_day = 2 AND p2.id_hour = h1.id_hour AND p2.id_class = '".$q."'\n"
|
||
|
|
||
|
. "LEFT JOIN lessons AS l2 ON p2.id_lesson = l2.id_lesson\n"
|
||
|
|
||
|
. "LEFT JOIN plan as p3 ON p3.id_day = 3 AND p3.id_hour = h1.id_hour AND p3.id_class = '".$q."'\n"
|
||
|
|
||
|
. "LEFT JOIN lessons AS l3 ON p3.id_lesson = l3.id_lesson\n"
|
||
|
|
||
|
. "LEFT JOIN plan as p4 ON p4.id_day = 4 AND p4.id_hour = h1.id_hour AND p4.id_class = '".$q."'\n"
|
||
|
|
||
|
. "LEFT JOIN lessons AS l4 ON p4.id_lesson = l4.id_lesson\n"
|
||
|
|
||
|
. "LEFT JOIN plan as p5 ON p5.id_day = 5 AND p5.id_hour = h1.id_hour AND p5.id_class = '".$q."'\n"
|
||
|
|
||
|
. "LEFT JOIN lessons AS l5 ON p5.id_lesson = l5.id_lesson\n"
|
||
|
|
||
|
. "\n"
|
||
|
|
||
|
. "ORDER BY h1.id_hour";
|
||
|
$result = mysqli_query($con,$sql);
|
||
|
echo "<table>
|
||
|
<tr>
|
||
|
<th>Godzina</th>
|
||
|
<th>Poniedziałek</th>
|
||
|
<th>Wtorek</th>
|
||
|
<th>Sroda</th>
|
||
|
<th>Czwartek</th>
|
||
|
<th>Piatek</th>
|
||
|
</tr>";
|
||
|
while($row = mysqli_fetch_array($result)) {
|
||
|
echo "<tr>";
|
||
|
echo "<td>" . $row['timestamp'] . "</td>";
|
||
|
echo "<td>" . $row['poniedzialek'] . "</td>";
|
||
|
echo "<td>" . $row['wtorek'] . "</td>";
|
||
|
echo "<td>" . $row['sroda'] . "</td>";
|
||
|
echo "<td>" . $row['czwartek'] . "</td>";
|
||
|
echo "<td>" . $row['piatek'] . "</td>";
|
||
|
|
||
|
echo "</tr>";
|
||
|
}
|
||
|
|
||
|
echo "</table>";
|
||
|
mysqli_close($con);
|
||
|
?>
|
||
|
</body>
|
||
|
</html>
|