This repository was archived by the owner on Nov 16, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathsingle.php
79 lines (65 loc) · 2.59 KB
/
single.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
<?php
require_once("config/init.php");
require_once("config/dbqueries.php");
if(!isset($_SESSION['user']))
{
header('location: http://localhost/phpscript/login.php');
}
$questionID = $_GET['id'];
if($_SERVER['REQUEST_METHOD'] == "POST")
{
addAnswer($_POST['answer'],$questionID,$_SESSION['user']->id,$conn);
header('location: http://localhost/phpscript/single.php?id='.$questionID);
}
$selectedQuestion = getQuestion($questionID,$conn)[0];
//var_dump(getAnswersOf($questionID,$conn));
?>
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta http-equiv="X-UA-Compatible" content="ie=edge">
<link rel="stylesheet" href="css/bootstrap.min.css">
<link rel="stylesheet" href="css/style.css">
<link href="https://fonts.googleapis.com/css?family=Berkshire+Swash" rel="stylesheet">
<title>QAnswers</title>
</head>
<body>
<?php
require_once("template/navbar.view.php");
?>
<div class="container">
<div class="row">
<div class="col-md-3">
<?php
require_once("template/sidebare.view.php");
?>
</div>
<div class="col-md-9">
<div class="question-section">
<h4><?= $selectedQuestion->question ?>?</h4>
<span class="question-info" >Question added by <a href="#" ><?= $selectedQuestion->username ?></a> in <a href="#"> <?= $selectedQuestion->category ?> </a></span>
</div>
<form method="POST" action="">
<div class="question-post">
<textarea name="answer" placeholder="You should ..."></textarea>
<div class="question-action">
<input type="submit" value="Post Answer" class="btn btn-danger">
</div>
</div>
</form>
<?php foreach (getAnswersOf($questionID,$conn) as $value):?>
<div class="answer-section">
<div class="autor-info">
<img class="profile-img" src="uploads/<?= $_SESSION['user']->avatar ?>" alt="">
<span class="author-name" ><?= $value->login ?></span>
</div>
<p><?= $value->content ?></p>
</div>
<?php endforeach; ?>
</div>
</div>
</div>
</body>
</html>