-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathblog_randomizer.php
57 lines (42 loc) · 1.29 KB
/
blog_randomizer.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
<?php
require_once("blog_db.php");
$db = new DB();
$permission = 0;
if(isset($_SESSION["userID"])) {
$permission = 1;
}
if(isset($_SESSION["admin"])) {
if($_SESSION["admin"] == 1) {
$permission = 10;
}
}
$blogGet = "SELECT blogID, blogTitle, blogDescription FROM blog WHERE permissionStatus<=$permission";
$matrix = $db->getData($blogGet);
for ($i=0;$i<count($matrix);$i++){
$randomizer=$matrix[$i][1];
}
//$i = rand(0,count($matrix)-1);
$i=0;
shuffle($matrix);
if(count($matrix)<6) {
while ($i<count($matrix)) {
echo ("<div class='randomBlog'>
<h3 class='postH3'>
<a href='blog_blog.php?blogID=".$matrix[$i][0]."'>".$matrix[$i][1]."</a>
</h3><hr>
".$matrix[$i][2]."
</div>");
$i++;
}
} else {
while ($i<6) {
echo ("<div class='randomBlog'>
<h3 class='postH3'>
<a href='blog_blog.php?blogID=".$matrix[$i][0]."'>".$matrix[$i][1]."</a>
</h3><hr>
".$matrix[$i][2]."
</div>");
$i++;
}
}
?>