diff --git a/database.sql b/database.sql index 5c0a5b2..33f364f 100644 --- a/database.sql +++ b/database.sql @@ -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) +); \ No newline at end of file diff --git a/js/index.js b/js/index.js index df1c4d2..6c3ea87 100755 --- a/js/index.js +++ b/js/index.js @@ -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(); diff --git a/php/videoload.php b/php/videoload.php index cd8ac57..c6c73f6 100755 --- a/php/videoload.php +++ b/php/videoload.php @@ -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 {