Commit 9f477c3ab8ed31a23386985144553b06e2bd8e6e

Authored by Jean Wasilewski
1 parent c85fa6bd

News editing

Showing 1 changed file with 6 additions and 3 deletions   Show diff stats
news.php
... ... @@ -2,7 +2,7 @@
2 2  
3 3 echo "<h2> News ";
4 4 if(isset($_SESSION["admin"])&&$_SESSION["admin"])
5   - echo '<h3><button type="button" class="btn btn-primary"><span class="glyphicon glyphicon-plus"></span> Nouvel article</button></h3>';
  5 + echo '<h3><button type="button" class="btn btn-primary" onClick="addNews();"><span class="glyphicon glyphicon-plus"></span> Nouvel article</button></h3>';
6 6 echo "</h2>";
7 7  
8 8 $link = mysql_connect(__MYSQL_HOSTNAME__, __MYSQL_USERNAME__, __MYSQL_PASSWORD__)
... ... @@ -14,7 +14,7 @@ if(!mysql_select_db(&#39;crep&#39;, $link)){
14 14 exit;
15 15 }
16 16  
17   -$requete = "select title, content, users.realname as userName from news, users where news.fk_author=users.pk;";
  17 +$requete = "select news.pk as pk, title, content, users.realname as userName from news, users where news.fk_author=users.pk;";
18 18 $resultat = mysql_query($requete);
19 19  
20 20 //Pour debugger
... ... @@ -27,7 +27,10 @@ if (!$resultat) {
27 27 while ($row = mysql_fetch_assoc($resultat)) {
28 28 echo '<div class="panel panel-default">';
29 29 echo '<div class="panel-heading">';
30   - echo '<h3 class="panel-title">'.$row['title'].'</h3>';
  30 + echo '<h3 class="panel-title">'.$row['title'];
  31 + if(isset($_SESSION["admin"])&&$_SESSION["admin"])
  32 + echo '<a href="#" onclick="editNews('.$row["pk".')" class="glyphicon glyphicon-pencil"></span>';
  33 + echo '</h3>';
31 34 echo '</div>';
32 35 echo '<div class="panel-body">';
33 36 echo '<p>'.$row['content'].'</p>';
... ...