diff --git a/baza/bloggero.sql b/baza/bloggero.sql index a9ca77a..90aeced 100644 --- a/baza/bloggero.sql +++ b/baza/bloggero.sql @@ -3,7 +3,7 @@ -- https://www.phpmyadmin.net/ -- -- Host: 127.0.0.1 --- Czas generowania: 01 Gru 2018, 22:48 +-- Czas generowania: 06 Gru 2018, 00:50 -- Wersja serwera: 10.1.36-MariaDB -- Wersja PHP: 7.2.11 @@ -56,7 +56,8 @@ CREATE TABLE `comments` ( INSERT INTO `comments` (`comment_id`, `post_id`, `username`, `tekst`, `data_dodania`, `data_modyfikacji`) VALUES (1, 18, 'użytkownik testowy 1', 'Komentarz Lorem ipsum dolor sit amet, consectetur adipiscing elit. Pellentesque nec ipsum ultrices, condimentum elit nec, luctus neque. Interdum et malesuada fames ac ante ipsum primis in faucibus. Donec eget ullamcorper ante. Donec fermentum erat nisi, eu dapibus neque ultrices et. Sed at sapien consectetur, iaculis dui non, sagittis mi. Nam consequat tempus felis at pretium. Cras ut lacus id ipsum interdum ullamcorper. In eget urna sed orci aliquam consequat. Morbi iaculis eros vel orci imperdiet ornare. Nulla quis dignissim ante. Etiam non rhoncus lectus, sit amet porta nunc. Cras at ultrices diam. Aenean arcu sapien, efficitur quis rutrum in, euismod et turpis.', '2018-12-01 22:11:16', '2018-12-01 22:11:16'), -(2, 18, 'użytkownik testowy 2', 'Drugi komentarz ale krótki Lorem ipsum dolor sit amet, consectetur adipiscing elit. Pellentesque nec ipsum ultrices, condimentum elit nec, luctus neque. ', '2018-12-01 22:12:04', '2018-12-01 22:12:04'); +(2, 18, 'użytkownik testowy 2', 'Drugi komentarz ale krótki Lorem ipsum dolor sit amet, consectetur adipiscing elit. Pellentesque nec ipsum ultrices, condimentum elit nec, luctus neque. ', '2018-12-01 22:12:04', '2018-12-01 22:12:04'), +(5, 0, '', 'Sprawdzam czy dodawanie komentarzy działa, jeśli tak to bardzo się cieszę. Trzeba jeszcze ogarnąć żeby zaciągało użytkownika który jako zalogowany komentuje no i żeby nie wyświetlało opcji komentowania dla bobów, którzy nie są zalogowani :).', '2018-12-05 20:55:29', '2018-12-05 20:55:29'); -- -------------------------------------------------------- @@ -89,6 +90,28 @@ INSERT INTO `post` (`post_id`, `blog_id`, `tytul`, `opis`, `tekst`, `image`, `da -- -------------------------------------------------------- +-- +-- Struktura tabeli dla tabeli `rating` +-- + +CREATE TABLE `rating` ( + `post_id` int(11) NOT NULL, + `user_id` int(11) NOT NULL, + `rating` int(11) NOT NULL +) ENGINE=InnoDB DEFAULT CHARSET=latin2; + +-- +-- Zrzut danych tabeli `rating` +-- + +INSERT INTO `rating` (`post_id`, `user_id`, `rating`) VALUES +(0, 0, 5), +(0, 0, 5), +(0, 0, 3), +(0, 0, 1); + +-- -------------------------------------------------------- + -- -- Struktura tabeli dla tabeli `user` -- @@ -157,7 +180,7 @@ ALTER TABLE `blog` -- AUTO_INCREMENT dla tabeli `comments` -- ALTER TABLE `comments` - MODIFY `comment_id` int(11) NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=3; + MODIFY `comment_id` int(11) NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=6; -- -- AUTO_INCREMENT dla tabeli `post` diff --git a/blog-post/blog.php b/blog-post/blog.php index 06c262c..35121b2 100644 --- a/blog-post/blog.php +++ b/blog-post/blog.php @@ -79,7 +79,7 @@ if ($sql = $mysqli->prepare("SELECT * FROM user WHERE user_id = 2 "))

$username

- +
@@ -87,7 +87,7 @@ if ($sql = $mysqli->prepare("SELECT * FROM user WHERE user_id = 2 "))
- +
$TW
diff --git a/blog-post/comment.php b/blog-post/comment.php new file mode 100644 index 0000000..9e16870 --- /dev/null +++ b/blog-post/comment.php @@ -0,0 +1,22 @@ +real_escape_string($_POST['tekst']); + $_SESSION['tekst'] = $tekst; + $sql = "INSERT INTO comments (tekst)" + . "Values ('$tekst')"; + + if($mysqli->query($sql) === true){ + $_SESSION['message'] = "Dodanie komentarza się powiodło!"; + header("location:post.php"); + } + else{ + $_SESSION['message'] = "Nie udało się dodać komentarza!"; + } + } + + + + +?> \ No newline at end of file diff --git a/blog-post/css/style.css b/blog-post/css/style.css index 71c3119..6edc748 100644 --- a/blog-post/css/style.css +++ b/blog-post/css/style.css @@ -20,6 +20,15 @@ h1, h2 { font-weight: 300; } +z { + font-size: 19px; + line-height: 2.3; + text-align: left; + left: -3px; + position: relative; +} + + post { font-size: 18px; @@ -68,12 +77,23 @@ post { letter-spacing: 1px; } +.name-desc h1 { + font-family: 'Oswald', sans-serif; + font-size: 35px; + line-height: 1; + font-weight: 300; + text-align: center; + margin-top:15px; + + } .name-desc h2 { font-family: 'Oswald', sans-serif; - font-size: 40px; + font-size: 28px; line-height: 1.45; font-weight: 300; + text-align: center; + } .name-desc h4 { @@ -81,8 +101,12 @@ post { font-size: 19px; line-height: 1.45; font-weight: 300; - text-align: right; - margin-bottom: 30; + text-align: right; + margin-bottom: -50; + position: relative; + top: 0px; + + } .name-desc h5 { font-family: 'Oswald', sans-serif; @@ -219,4 +243,45 @@ object-fit:none; } .scale-down img{ object-fit:scale-down; +} + +/* Ocena gwiazdki */ +*{ + margin: 0; + padding: 0; +} +.rate { + float: left; + height: 46px; + padding: 0 10px; +} +.rate:not(:checked) > input { + position:absolute; + top:-9999px; +} +.rate:not(:checked) > label { + float:right; + width:1em; + overflow:hidden; + white-space:nowrap; + cursor:pointer; + font-size:30px; + color:#ccc; +} +.rate:not(:checked) > label:before { + content: '★ '; +} +.rate > input:checked ~ label { + color: #f4c741; +} +.rate:not(:checked) > label:hover, +.rate:not(:checked) > label:hover ~ label { + color: #deb217; +} +.rate > input:checked + label:hover, +.rate > input:checked + label:hover ~ label, +.rate > input:checked ~ label:hover, +.rate > input:checked ~ label:hover ~ label, +.rate > label:hover ~ input:checked ~ label { + color: #f4c741; } \ No newline at end of file diff --git a/blog-post/post.php b/blog-post/post.php index 4974e63..eb01a98 100644 --- a/blog-post/post.php +++ b/blog-post/post.php @@ -18,7 +18,7 @@ - + @@ -78,10 +78,44 @@ if ($sql = $mysqli->prepare("SELECT * FROM post WHERE post_id = 18"))
- $main -

$date

+ $main +
- "; + +
+
+
+
+
+

$date

+

+
+
+
+
+ Ocena: + + + + + + + + + + + + +
+
+
+ +
+ +
+
+
+
"; } $sql->close(); @@ -94,7 +128,7 @@ if ($sql = $mysqli->prepare("SELECT * FROM comments ORDER BY comment_id")) { $sql->execute(); $sql->bind_result($comment_id,$post_id,$username,$tekst,$data_dodania, $data_modyfikacji); - echo "

Komentarze

"; + echo "

Komentarze

"; while ($sql->fetch()) { @@ -108,14 +142,39 @@ if ($sql = $mysqli->prepare("SELECT * FROM comments ORDER BY comment_id")) $sql->close(); } else die( "Błąd w zapytaniu SQL! Sprawdź kod SQL w PhpMyAdmin." ); - - echo "

Dodaj komentarz:

"; + + + echo "

Dodaj komentarz:

+ +
+
+
+
+
+
+
+ +
+
+
+
+
+
+
+ +
+
+
+
+
+
"; + $mysqli->close(); ?> - + diff --git a/blog-post/rating.php b/blog-post/rating.php new file mode 100644 index 0000000..cca2c1b --- /dev/null +++ b/blog-post/rating.php @@ -0,0 +1,22 @@ +real_escape_string($_POST['rating']); + $_SESSION['rating'] = $rating; + $sql = "INSERT INTO rating (rating)" + . "Values ($rating)"; + + if($mysqli->query($sql) === true){ + $_SESSION['message'] = "Dodanie oceny się powiodło!"; + header("location:post.php"); + } + else{ + $_SESSION['message'] = "Nie udało się dodać ooceny!"; + } + } + + + + +?> \ No newline at end of file