-
Notifications
You must be signed in to change notification settings - Fork 0
/
post_display.php
48 lines (46 loc) · 1.4 KB
/
post_display.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
<?php
session_start();
if (isset($_GET['id'])) {
require_once('db_constants.php');
$bdd = new PDO('mysql:host=' . DB_HOST . ';dbname=' . DB_NAME . ';charset=utf8', DB_USERNAME, DB_PASSWORD);
$categories = json_decode($_SESSION['categories'], true);
$request = $bdd->prepare("SELECT * FROM ".TABLE_POSTS." WHERE id = :id");
$request->bindParam(":id", $_GET['id']);
if($request->execute()) {
$row = $request->fetch();
$to_display = "";
foreach (json_decode($row['categories'], true) as $i) { $to_display .= $categories[$i].", "; }
$days = array('', 'Janvier', 'Février', 'Mars', 'Avril', 'Mai', 'Juin', 'Juillet', 'Août', 'Septembre', 'Octobre', 'Novembre', 'Décembre');
$date = getdate(strtotime($row['date']));
?>
<div class="article" id="<?php echo $row['id'];?>">
<div class="short_desc">
<h1><?php echo $row['name'];?></h1>
<p>Publié le <?php echo $date['mday'] ." ".strtolower($days[$date['mon']]). " ".$date['year'];?> | <?php echo rtrim($to_display, ", "); ?> </p>
</div>
<div id="content">
<img class="img_pra fl" src="<?php echo $row['picture'];?>"/>
<div><?php echo html_entity_decode($row['content']); ?></div>
</div>
</div>
<?php
}
} ?>
<style>
#content div {
text-align: justify;
}
.img_pra {
max-width: 500px;
max-height: 500px;
width: auto;
height: auto;
}
#content > img {
width: auto;
height: auto;
}
.article {
margin: 0 40px;
}
</style>