Commit ec9f5496aeef98cd6e32553048dddc24b8c3ca01
1 parent
4511fbe6
Added add element on news.php
Showing
1 changed file
with
34 additions
and
31 deletions
Show diff stats
news.php
1 | -<h2> News </h2> | 1 | +<?php |
2 | 2 | ||
3 | -<?php | ||
4 | - require_once("creds.php"); | ||
5 | - $link = mysql_connect(__MYSQL_HOSTNAME__, __MYSQL_USERNAME__, __MYSQL_PASSWORD__) | ||
6 | - or die("Impossible de se connecter : " . mysql_error()); | 3 | +echo "<h2> News "; |
4 | +if(isset($_SESSION["admin"])&&$_SESSION["admin"]) | ||
5 | + echo '<span class="label label-primary"><span class="glyphicon glyphicon-plus"></span> Nouvel article</span>'; | ||
6 | +echo "</h2>"; | ||
7 | + | ||
8 | +$link = mysql_connect(__MYSQL_HOSTNAME__, __MYSQL_USERNAME__, __MYSQL_PASSWORD__) | ||
9 | + or die("Impossible de se connecter : " . mysql_error()); | ||
7 | 10 | ||
8 | 11 | ||
9 | - if(!mysql_select_db('crep', $link)){ | ||
10 | - echo 'Selection de la base de donnees impossible'; | ||
11 | - exit; | ||
12 | - } | 12 | +if(!mysql_select_db('crep', $link)){ |
13 | + echo 'Selection de la base de donnees impossible'; | ||
14 | + exit; | ||
15 | +} | ||
13 | 16 | ||
14 | - $requete = "select title, content, users.realname as userName from news, users where news.fk_author=users.pk;"; | ||
15 | - $resultat = mysql_query($requete); | 17 | +$requete = "select title, content, users.realname as userName from news, users where news.fk_author=users.pk;"; |
18 | +$resultat = mysql_query($requete); | ||
16 | 19 | ||
17 | - //Pour debugger | ||
18 | - if (!$resultat) { | ||
19 | - $message = 'Requete invalide : ' . mysql_error() . "\n"; | ||
20 | - $message .= 'Requete complete : ' . $query; | ||
21 | - die($message); | ||
22 | - } | 20 | +//Pour debugger |
21 | +if (!$resultat) { | ||
22 | + $message = 'Requete invalide : ' . mysql_error() . "\n"; | ||
23 | + $message .= 'Requete complete : ' . $query; | ||
24 | + die($message); | ||
25 | +} | ||
23 | 26 | ||
24 | - while ($row = mysql_fetch_assoc($resultat)) { | ||
25 | - echo '<div class="panel panel-default">'; | ||
26 | - echo '<div class="panel-heading">'; | ||
27 | - echo '<h3 class="panel-title">'.$row['title'].'</h3>'; | ||
28 | - echo '</div>'; | ||
29 | - echo '<div class="panel-body">'; | ||
30 | - echo '<p>'.$row['content'].'</p>'; | ||
31 | - echo '</div>'; | ||
32 | - echo '<div class="panel-footer">'; | ||
33 | - echo '<p>'.$row['userName'].'</p>'; | ||
34 | - echo '</div></div>'; | ||
35 | - } | 27 | +while ($row = mysql_fetch_assoc($resultat)) { |
28 | + echo '<div class="panel panel-default">'; | ||
29 | + echo '<div class="panel-heading">'; | ||
30 | + echo '<h3 class="panel-title">'.$row['title'].'</h3>'; | ||
31 | + echo '</div>'; | ||
32 | + echo '<div class="panel-body">'; | ||
33 | + echo '<p>'.$row['content'].'</p>'; | ||
34 | + echo '</div>'; | ||
35 | + echo '<div class="panel-footer">'; | ||
36 | + echo '<p>'.$row['userName'].'</p>'; | ||
37 | + echo '</div></div>'; | ||
38 | +} | ||
36 | 39 | ||
37 | - //On libere l'espace de resultat | ||
38 | - mysql_close($link); | 40 | +//On libere l'espace de resultat |
41 | +mysql_close($link); | ||
39 | ?> | 42 | ?> |
40 | 43 |