From 354cb554fd85e6b2a991c3b693636defbb603c80 Mon Sep 17 00:00:00 2001 From: Jessica Andjani Date: Sun, 11 Oct 2015 16:38:31 +0700 Subject: [PATCH 1/7] css, front page, question, answer(unfinished) --- answer.php | 96 ++++++++++++++++++++++++++++++ data-answer.php | 16 +++++ data-question.php | 16 +++++ index.php | 74 +++++++++++++++++++++++ question.html | 30 ++++++++++ style.css | 146 ++++++++++++++++++++++++++++++++++++++++++++++ 6 files changed, 378 insertions(+) create mode 100644 answer.php create mode 100644 data-answer.php create mode 100644 data-question.php create mode 100644 index.php create mode 100644 question.html create mode 100644 style.css diff --git a/answer.php b/answer.php new file mode 100644 index 0000000..b28acbd --- /dev/null +++ b/answer.php @@ -0,0 +1,96 @@ + + + + + +
+

Simple StackExchange



+

The question topic goes here

+
+
+
+
+
+

2

+
+
+
+ +
+


+ +

+
+

asked by at | + + edit + | + delete

+
+
+
+

1 Answer

+
+ +
+
+
+
+

2

+
+
+
+
+

+
+

asked by at

+
+
+
+ + +

  Your Answer

+
+
+ + + +
+ +
+
+ + \ No newline at end of file diff --git a/data-answer.php b/data-answer.php new file mode 100644 index 0000000..9df886d --- /dev/null +++ b/data-answer.php @@ -0,0 +1,16 @@ + \ No newline at end of file diff --git a/data-question.php b/data-question.php new file mode 100644 index 0000000..301623d --- /dev/null +++ b/data-question.php @@ -0,0 +1,16 @@ + \ No newline at end of file diff --git a/index.php b/index.php new file mode 100644 index 0000000..056392e --- /dev/null +++ b/index.php @@ -0,0 +1,74 @@ + + + + + + +
+

Simple StackExchange


+
+   + +
+
+

Cannot find what you are looking for?Ask here

+
+

Recently Asked Questions

+
+
+ + +
+ +
+
+

0

+
+

Votes

+
+
+
+

0

+
+

Answers

+
+ +
+ +


+

+
+

asked by | + + edit + | + delete

+
+
+
+
+ + +
+
+ + \ No newline at end of file diff --git a/question.html b/question.html new file mode 100644 index 0000000..3c397e9 --- /dev/null +++ b/question.html @@ -0,0 +1,30 @@ + + + + + + +
+

Simple StackExchange



+

What's your question?

+
+
+
+ + + + +
+ +
+
+ + \ No newline at end of file diff --git a/style.css b/style.css new file mode 100644 index 0000000..0b9eda3 --- /dev/null +++ b/style.css @@ -0,0 +1,146 @@ +/* Index CSS */ +h1 { + font-size: 45px; +} +hr { + border: 2px solid; + margin-top: -13px; +} +h2{ + margin-left: 16px; +} +.number-votes h2 { + color: #888888; + margin: 2px 5px 5px 23px; +} +.answer-h2 { + font-size: 33px; + margin-left: 0px; +} +.search-form { + margin: 0px 0px -7px 40px; +} +.stackExchange { + margin-left: 195px; + margin-right: 199px; +} +.search-bar { + width: 790px; + height: 28px; + border: 3px solid black; +} +.search-button { + width: 83px; + height: 34px; + border: 3px solid black; + background-color: white; +} +.question-list { + display: inline-block; + margin-bottom: 50px; +} +.question-description { + display: inline-block; + padding: 2px 5px 2px 0px; + border-bottom: 4px solid black; + float: left; +} +.votes-answers { + float: left; + margin-right: 54px; +} +.votes { + display: inline-block; + text-align: center; + margin-right: 5px; + padding: 5px 20px 5px 20px; + float: left; +} +.answers { + display: inline-block; + text-align: center; + margin-right: 50px; + padding: 5px 20px 5px 20px; + float: left; +} +.question-topic { + display: inline-block; + float: left; + width: 648px; + padding: 8px 12px 8px 25px; +} +.question-topic h3 { + margin: 17px 0px 11px 0px; +} +.question-content { + display: inline-block; + text-align: center; + margin-right: 5px; + padding: 5px 30px 5px 40px; +} +.ask-description { + line-height: 0px; + float: right; +} + +/* Question CSS */ +.question-form { + margin: 40px 4px 20px 5px; +} +.question-container label { + display: block; + margin-bottom: 7px; +} +.question-container input { + width: 100%; + height: 37px; + border: 1px solid black; +} +.question-container textarea { + width: 99.5%; + height: 150px; + border: 1px solid black; +} +.post-button { + float: right; + width: 75px; + height: 40px; + margin-bottom: 50px; + border: 1px solid black; +} +/* Answer CSS */ +.vote-up { + width: 0px; + height: 0px; + border-left: 10px solid transparent; + border-right: 10px solid transparent; + border-bottom: 16px solid #dbdbdb; + margin: 20px 5px 5px 20px; +} +.vote-down { + width: 0px; + height: 0px; + border-left: 10px solid transparent; + border-right: 10px solid transparent; + border-top: 16px solid #dbdbdb; + margin: 7px 5px 5px 20px; +} +.number { + float: left; + margin-right: 35px; +} +.QA-content { + display: inline-block; + float: left; + width: 849px; + padding: 8px 5px 8px 5px; +} +.question { + display: inline-block; + margin-bottom: -5px; +} +.answer { + display: inline-block; + padding: 0px 0px 2px 0px; + border-bottom: 4px solid black; +} From d274a4ca44732d6bf0d8a2e653936dbd501dd314 Mon Sep 17 00:00:00 2001 From: Jessica Andjani Date: Mon, 12 Oct 2015 17:59:26 +0700 Subject: [PATCH 2/7] koreksi pada query di answer, koreksi pada insert di data answer, edit question, koreksi nama atribut pada index.php --- answer.php | 6 +++--- data-answer.php | 2 +- edit-question.php | 48 +++++++++++++++++++++++++++++++++++++++++++++ index.php | 2 +- update-question.php | 18 +++++++++++++++++ 5 files changed, 71 insertions(+), 5 deletions(-) create mode 100644 edit-question.php create mode 100644 update-question.php diff --git a/answer.php b/answer.php index b28acbd..e21efd9 100644 --- a/answer.php +++ b/answer.php @@ -29,7 +29,7 @@ $email = mysql_result($result, 0, "email"); $topic = mysql_result($result, 0, "topic"); $content = mysql_result($result, 0, "content"); - $vote = mysql_result($result, 0, "vote"); + $vote_question = mysql_result($result, 0, "vote_question"); $date_question = mysql_result($result, 0, "date_question"); ?>
@@ -48,7 +48,7 @@

1 Answer


diff --git a/data-answer.php b/data-answer.php index 9df886d..d1b4a89 100644 --- a/data-answer.php +++ b/data-answer.php @@ -9,7 +9,7 @@ $question_id = $_GET["id"]; $connection = mysql_connect($servername, $username, $password) or die(mysql_error()); @mysql_select_db('stackexchange') or die(mysql_error()); - $sql = "INSERT INTO answer (`name`, `email`, `content`) VALUES('$name', '$email','$content')"; + $sql = "INSERT INTO answer (`question_id`, `name`, `email`, `content`) VALUES('$question_id', '$name', '$email','$content')"; mysql_query($sql); mysql_close(); header("Location: /Tubes1/answer.php?id=$question_id"); diff --git a/edit-question.php b/edit-question.php new file mode 100644 index 0000000..c076cbb --- /dev/null +++ b/edit-question.php @@ -0,0 +1,48 @@ + + + + + + +
+

Simple StackExchange



+

What's your question?

+
+ +
+
+ + + + +
+ +
+
+ + \ No newline at end of file diff --git a/index.php b/index.php index 056392e..ea576da 100644 --- a/index.php +++ b/index.php @@ -35,7 +35,7 @@ $email = mysql_result($result, $i, "email"); $topic = mysql_result($result, $i, "topic"); $content = mysql_result($result, $i, "content"); - $vote = mysql_result($result, $i, "vote"); + $vote_question = mysql_result($result, $i, "vote_question"); ?>
diff --git a/update-question.php b/update-question.php new file mode 100644 index 0000000..551f8c6 --- /dev/null +++ b/update-question.php @@ -0,0 +1,18 @@ + \ No newline at end of file From 266c2f93d6c2e18968a05e2ac8243f7d3b2cba7c Mon Sep 17 00:00:00 2001 From: Jessica Andjani Date: Mon, 12 Oct 2015 23:24:11 +0700 Subject: [PATCH 3/7] penambahan link delete pada answer.php dan index.php, delete-question.php --- answer.php | 4 +++- delete-question.php | 13 +++++++++++++ index.php | 4 +++- 3 files changed, 19 insertions(+), 2 deletions(-) create mode 100644 delete-question.php diff --git a/answer.php b/answer.php index e21efd9..ad2a922 100644 --- a/answer.php +++ b/answer.php @@ -41,7 +41,9 @@ edit | - delete + + delete +
diff --git a/delete-question.php b/delete-question.php new file mode 100644 index 0000000..4528b53 --- /dev/null +++ b/delete-question.php @@ -0,0 +1,13 @@ + \ No newline at end of file diff --git a/index.php b/index.php index ea576da..fb5e015 100644 --- a/index.php +++ b/index.php @@ -61,7 +61,9 @@ edit | - delete + + delete +
From bd6a25e7573daf6baed385a4ee9627060257e760 Mon Sep 17 00:00:00 2001 From: Jessica Andjani Date: Tue, 13 Oct 2015 22:35:24 +0700 Subject: [PATCH 4/7] vote question pada halaman jawaban, vote answer pada halaman jawaban (unfinished) --- answer.php | 40 +++++++++++++------- function.js | 83 ++++++++++++++++++++++++++++++++++++++++++ vote-down-answer.php | 13 +++++++ vote-down-question.php | 12 ++++++ vote-up-answer.php | 13 +++++++ vote-up-question.php | 12 ++++++ 6 files changed, 160 insertions(+), 13 deletions(-) create mode 100644 function.js create mode 100644 vote-down-answer.php create mode 100644 vote-down-question.php create mode 100644 vote-up-answer.php create mode 100644 vote-up-question.php diff --git a/answer.php b/answer.php index ad2a922..8590d77 100644 --- a/answer.php +++ b/answer.php @@ -1,6 +1,8 @@ + +
@@ -8,13 +10,6 @@

The question topic goes here


-
-
-
-

2

-
-
-
+
+
+
+

+
+
+
+
-


- +


+

-

asked by at | +

asked by at | edit | @@ -55,6 +62,7 @@ $num = mysql_num_rows($result); $i = 0; while ($i < $num) { + $answer_id = mysql_result($result, $i, "answer_id"); $name = mysql_result($result, $i, "name"); $email = mysql_result($result, $i, "email"); $content = mysql_result($result, $i, "content"); @@ -63,11 +71,16 @@ ?>
-
+
+
-

2

+

-
+

@@ -94,5 +107,6 @@
+ \ No newline at end of file diff --git a/function.js b/function.js new file mode 100644 index 0000000..0df41ff --- /dev/null +++ b/function.js @@ -0,0 +1,83 @@ +/*********************** Vote Question **********************/ +/* Vote Up Question */ +var votesUpQuestion = document.getElementsByClassName("vote-up-question"); +for (var i = 0; i < votesUpQuestion.length; i++){ + votesUpQuestion[i].onclick = function() { + voteUp_Question(this.getAttribute("data-question-id")); + } +} +/* Vote Down Question */ +var votesDownQuestion = document.getElementsByClassName("vote-down-question"); +for (var i = 0; i < votesDownQuestion.length; i++) { + votesDownQuestion[i].onclick = function() { + voteDown_Question(this.getAttribute("data-question-id")); + } +} + +/*********************** Vote Answer **********************/ +/* Vote Up Answer */ +var votesUpAnswer = document.getElementsByClassName("vote-up-answer"); +for (var i = 0; i < votesUpAnswer.length; i++) { + votesUpAnswer[i].onclick = function() { + voteUp_Answer(this.getAttribute("data-question-id"), this.getAttribute("data-answer-id")); + } +} +/* Vote Down Answer */ +var votesDownAnswer = document.getElementsByClassName("vote-down-answer"); +for (var i = 0; i < votesDownAnswer.length; i++) { + votesDownAnswer[i].onclick = function() { + voteDown_Answer(this.getAttribute("data-question-id"), this.getAttribute("data-answer-id")); + } +} + +/*********************** Ajax Vote Question **********************/ +/* Vote Up Question */ +function voteUp_Question(id_question) { + var xmlhttp = new XMLHttpRequest(); + var count = parseInt(document.getElementById('count_vote_question').innerHTML); + xmlhttp.onreadystatechange = function() { + if(xmlhttp.readyState == 4 && xmlhttp.status == 200) { + document.getElementById('count_vote_question').innerHTML = count+1; + } + } + xmlhttp.open("GET", "/Tubes1/vote-up-question.php?id=" + id_question, true); + xmlhttp.send(); +} +/* Vote Down Question */ +function voteDown_Question(id_question) { + var xmlhttp = new XMLHttpRequest(); + var count = parseInt(document.getElementById('count_vote_question').innerHTML); + xmlhttp.onreadystatechange = function() { + if(xmlhttp.readyState == 4 && xmlhttp.status == 200) { + document.getElementById('count_vote_question').innerHTML = count-1; + } + } + xmlhttp.open("GET", "/Tubes1/vote-down-question.php?id=" + id_question, true); + xmlhttp.send(); +} + +/*********************** Ajax Vote Answer **********************/ +/* Vote Up Answer */ +function voteUp_Answer(id_question, id_answer) { + var xmlhttp = new XMLHttpRequest(); + var count = parseInt(document.getElementById('count_vote_answer').innerHTML); + xmlhttp.onreadystatechange = function() { + if(xmlhttp.readyState == 4 && xmlhttp.status == 200) { + document.getElementById('count_vote_answer').innerHTML = count+1; + } + } + xmlhttp.open("GET", "/Tubes1/vote-up-answer.php?id=" + id_question + "&id-ans=" + id_answer, true); + xmlhttp.send(); +} +/* Vote Down Answer */ +function voteDown_Answer(id_question, id_answer) { + var xmlhttp = new XMLHttpRequest(); + var count = parseInt(document.getElementById('count_vote_answer').innerHTML); + xmlhttp.onreadystatechange = function() { + if(xmlhttp.readyState == 4 && xmlhttp.status == 200) { + document.getElementById('count_vote_answer').innerHTML = count-1; + } + } + xmlhttp.open("GET", "/Tubes1/vote-down-answer.php?id=" + id_question + "&id-ans=" + id_answer, true); + xmlhttp.send(); +} \ No newline at end of file diff --git a/vote-down-answer.php b/vote-down-answer.php new file mode 100644 index 0000000..48ef285 --- /dev/null +++ b/vote-down-answer.php @@ -0,0 +1,13 @@ + \ No newline at end of file diff --git a/vote-down-question.php b/vote-down-question.php new file mode 100644 index 0000000..0278717 --- /dev/null +++ b/vote-down-question.php @@ -0,0 +1,12 @@ + \ No newline at end of file diff --git a/vote-up-answer.php b/vote-up-answer.php new file mode 100644 index 0000000..e13de1e --- /dev/null +++ b/vote-up-answer.php @@ -0,0 +1,13 @@ + \ No newline at end of file diff --git a/vote-up-question.php b/vote-up-question.php new file mode 100644 index 0000000..83968c5 --- /dev/null +++ b/vote-up-question.php @@ -0,0 +1,12 @@ + \ No newline at end of file From a285e5b986d0595dffe7dbea2ff14a3172176920 Mon Sep 17 00:00:00 2001 From: Jessica Andjani Date: Wed, 14 Oct 2015 21:47:50 +0700 Subject: [PATCH 5/7] vote answer pada bagian halaman utama dan halaman jawaban, validasi pada pengisian form pertanyaan dan jawaban, perbaikan link pada update --- answer.php | 10 ++++++---- edit-question.php | 3 ++- function.js | 47 +++++++++++++++++++++++++++++++++++++++++---- index.php | 11 ++++++++--- question.html | 3 ++- update-question.php | 1 - 6 files changed, 61 insertions(+), 14 deletions(-) diff --git a/answer.php b/answer.php index 8590d77..f1a893f 100644 --- a/answer.php +++ b/answer.php @@ -54,12 +54,14 @@

-

1 Answer

-
+

Answer

+
+
-

+

@@ -92,7 +94,7 @@

  Your Answer

-
+