added tags

This commit is contained in:
lukas 2020-05-24 11:49:37 +02:00
parent 90fdb64f85
commit 45d2838fa1
3 changed files with 41 additions and 9 deletions

View File

@ -1,9 +1,27 @@
create table if not exists tags
(
tag_id int auto_increment
primary key,
tag_name varchar(50) null
);
create table if not exists videos
(
movie_id int auto_increment
movie_id int auto_increment
primary key,
movie_name varchar(200) null,
movie_url varchar(200) null,
thumbnail mediumblob null,
likes int default 0 null
movie_name varchar(200) null,
movie_url varchar(200) null,
thumbnail mediumblob null,
likes int default 0 null,
create_date datetime default CURRENT_TIMESTAMP null
);
create table if not exists video_tags
(
tag_id int null,
video_id int null,
constraint video_tags_tags_tag_id_fk
foreign key (tag_id) references tags (tag_id),
constraint video_tags_videos_movie_id_fk
foreign key (video_id) references videos (movie_id)
);

View File

@ -5,10 +5,13 @@ let scrollposition = 0;
$(document).ready(function () {
$.post('php/videoload.php', 'action=getMovies', function (data) {
videos = data;
console.log(videos);
loadPreviewBlock(12);
}, 'json');
$.post('php/videoload.php', 'action=getDbSize', function (data) {
console.log(data);
}, 'json');
$(".closebutton").click(function () {
$(".videopagewrapper").hide();
$(".previewcontainer").show();

View File

@ -12,7 +12,7 @@ if (isset($_POST['action'])) {
$result = $conn->query($query);
$rows = array();
while ($r = mysqli_fetch_assoc($result)) {
array_push($rows,$r);
array_push($rows, $r);
}
echo(json_encode($rows));
@ -33,14 +33,14 @@ if (isset($_POST['action'])) {
$query = "SELECT table_schema AS \"Database\",
ROUND(SUM(data_length + index_length) / 1024 / 1024, 2) AS \"Size\"
FROM information_schema.TABLES
WHERE TABLE_SCHEMA='test'
WHERE TABLE_SCHEMA='hub'
GROUP BY table_schema;";
$result = $conn->query($query);
if ($result->num_rows == 1) {
$row = $result->fetch_assoc();
echo '{"data":"' . $row["Size"] . '"}';
echo '{"data":"' . $row["Size"] . 'MB"}';
}
break;
@ -52,6 +52,17 @@ if (isset($_POST['action'])) {
echo($row["thumbnail"]);
break;
case "getTags":
$query = "SELECT * FROM video_tags INNER JOIN tags t on video_tags.tag_id = t.tag_id WHERE video_id='" . $_POST['movieid'] . "'";
#$query = "SELECT thumbnail FROM videos WHERE movie_id='" . $_POST['movieid'] . "'";
$result = $conn->query($query);
$row = $result->fetch_assoc();
echo($row["thumbnail"]);
break;
}
} else {