created new category page

load random picture of category to tags list
This commit is contained in:
2020-06-07 15:48:27 +02:00
parent 516949dc65
commit 1459abf205
6 changed files with 161 additions and 3 deletions

36
api/Tags.php Normal file
View File

@ -0,0 +1,36 @@
<?php
require 'Database.php';
$conn = Database::getInstance()->getConnection();
if (isset($_POST['action'])) {
$action = $_POST['action'];
switch ($action) {
case "getAllTags":
$query = "SELECT tag_name,tag_id from tags";
$result = $conn->query($query);
$rows = array();
while ($r = mysqli_fetch_assoc($result)) {
array_push($rows, $r);
}
echo json_encode($rows);
break;
case "getRandomTagPreview":
$id = $_POST['id'];
$query = "SELECT thumbnail from videos
INNER JOIN video_tags vt on videos.movie_id = vt.video_id
WHERE tag_id='$id'
ORDER BY RAND()
LIMIT 1";
$result = $conn->query($query);
$r = mysqli_fetch_assoc($result);
echo $r['thumbnail'];
break;
}
}