forked from heyhellomila/SOEN341
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtabmenu.php
More file actions
131 lines (123 loc) · 5.4 KB
/
Copy pathtabmenu.php
File metadata and controls
131 lines (123 loc) · 5.4 KB
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
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
<?php
require_once("action/profilePageAction.php");
require_once("action/dba/MySQLrequests.php");
//make connection
$connection=connection::getConnection();
$statement = $connection->prepare("SELECT * FROM post ORDER BY post_nb_likes DESC LIMIT 3");
$statement->setFetchMode(PDO::FETCH_ASSOC);
$statement->execute();
$info = $statement->fetchAll();
$liked=$info;
$statement = $connection->prepare("SELECT * FROM post ORDER BY post_id DESC LIMIT 3");
$statement->setFetchMode(PDO::FETCH_ASSOC);
$statement->execute();
$info = $statement->fetchAll();
$newest=$info;
$statement = $connection->prepare("SELECT * FROM post ORDER BY post_id ASC LIMIT 3");
$statement->setFetchMode(PDO::FETCH_ASSOC);
$statement->execute();
$info = $statement->fetchAll();
$unpopular=$info;
connection::closeConnection();
?>
<div id="accordion">
<div class="container bg-white px-0" style="line-height: 0.5 !important;" `>
<!-- Nav tabs -->
<ul class="nav nav-tabs" role="tablist">
<li class="nav-item bg-light">
<a class="nav-link active font-weight-bold text-info" data-toggle="collapse" href="#activetab">Popular</a>
</li>
<li class="nav-item bg-light">
<a class="nav-link font-weight-bold text-info" data-toggle="collapse" href="#newtab">New</a>
</li>
<li class="nav-item bg-light">
<a class="nav-link font-weight-bold text-success" data-toggle="collapse" href="#unansweredtab">Unanswered</a>
</li>
</ul>
<!-- Tab panes -->
<div class="tab-content">
<div id="activetab" class="container collapse" data-parent="#accordion"><br>
<div class="container">
<!-- Table of posts -->
<div >
<!-- Single post that is added to the homepage starts here -->
<?php foreach ($liked as $post) {
$postCreator=MySQLrequests::getPostCreatorByPostID($post["post_creator"]);
?>
<div class="row border-bottom border-gray">
<div class="col">
<h5 class="row">
<form name="title" action="index.php" method="post">
<input type="hidden" name="post_id" value="<?=$post["post_id"]?>"></input>
<button type="submit" class="notButton"><?=$post["post_title"]?></button>
</form>
</h5>
<div class="my-1 text-muted small row">
<p class="m-0">
<strong class="text-gray-dark"> From: <?=$postCreator["user_name"]?><span style="color: green;"> Answers: <?=$post["post_nb_answers"]?> </span><span style="color: blue;">Likes: <?=$post["post_nb_likes"]?></span> Posted: <?=$post["post_creation_time"]?></strong>
</p>
</div>
</div>
</div>
<?php
} ?>
<!-- End of single post -->
</div>
</div>
</div>
<div id="newtab" class="container collapse" data-parent="#accordion"><br>
<div class="container">
<!-- Table of posts -->
<div>
<!-- Single post that is added to the homepage starts here -->
<?php foreach ($newest as $post) {
$postCreator=MySQLrequests::getPostCreatorByPostID($post["post_creator"]);
?>
<div class="row border-bottom border-gray">
<div class="col">
<h5 class="row">
<form name="title" action="index.php" method="post">
<input type="hidden" name="post_id" value="<?=$post["post_id"]?>"></input>
<button type="submit" class="notButton"><?=$post["post_title"]?></button>
</form>
</h5>
<div class="my-1 text-muted row">
<p class="small m-0">
<strong class="d-block text-gray-dark"> From: <?=$postCreator["user_name"]?><span style="color: green;"> Answers: <?=$post["post_nb_answers"]?> </span><span style="color: blue;">Likes: <?=$post["post_nb_likes"]?></span> Posted:<?=$post["post_creation_time"]?></strong>
</p>
</div></div>
</div>
<?php } ?>
<!-- End of single post -->
</div>
</div>
</div>
<div id="unansweredtab" class="container collapse" data-parent="#accordion"><br>
<div class="container">
<!-- Table of posts -->
<div>
<!-- Single post that is added to the homepage starts here -->
<?php foreach ($unpopular as $post) {
$postCreator=MySQLrequests::getPostCreatorByPostID($post["post_creator"]);
?>
<div class="row border-bottom border-gray"><div class="col">
<h5 class="row">
<form name="title" action="index.php" method="post">
<input type="hidden" name="post_id" value="<?=$post["post_id"]?>"></input>
<button type="submit" class="notButton"><?=$post["post_title"]?></button>
</form>
</h5>
<div class="my-1 text-muted row">
<p class="small m-0">
<strong class="d-block text-gray-dark"> From: <?=$postCreator["user_name"]?><span style="color: green;"> Answers: <?=$post["post_nb_answers"]?> </span><span style="color: blue;">Likes: <?=$post["post_nb_likes"]?></span> Posted: <?=$post["post_creation_time"]?></strong>
</p>
</div></div>
</div>
<?php } ?>
<!-- End of single post -->
</div>
</div>
</div>
</div>
</div>
</div>