Blame view

news.php 1.44 KB
ec9f5496   Jean Wasilewski   Added add element...
1
  <?php
02337ae1   Erwan Nanrocki   correction pour l...
2
  
ec9f5496   Jean Wasilewski   Added add element...
3
4
  echo "<h2> News ";
  if(isset($_SESSION["admin"])&&$_SESSION["admin"])
9f477c3a   Jean Wasilewski   News editing
5
  	echo '<h3><button type="button" class="btn btn-primary" onClick="addNews();"><span class="glyphicon glyphicon-plus"></span> Nouvel article</button></h3>';
ec9f5496   Jean Wasilewski   Added add element...
6
7
8
9
  echo "</h2>";
  
  $link = mysql_connect(__MYSQL_HOSTNAME__, __MYSQL_USERNAME__, __MYSQL_PASSWORD__)
  	or die("Impossible de se connecter : " . mysql_error());
1d10adb8   kevin   News.php modif Kevin
10
  	
bad01aa4   kevin   modification dans...
11
  	
ec9f5496   Jean Wasilewski   Added add element...
12
13
14
15
  if(!mysql_select_db('crep', $link)){
  	echo 'Selection de la base de donnees impossible';
  	exit;
  }
db8bf362   kevin   modif sur news.php
16
  	
92042353   Jean Wasilewski   Prettier display
17
  $requete = "select news.pk as pk, DATE_FORMAT(created,'%e-%m-%Y') AS created, title, content, users.realname as userName from news, users where news.fk_author=users.pk;";
ec9f5496   Jean Wasilewski   Added add element...
18
  $resultat = mysql_query($requete);
bad01aa4   kevin   modification dans...
19
  	
ec9f5496   Jean Wasilewski   Added add element...
20
21
22
23
24
25
  //Pour debugger
  if (!$resultat) {
  	$message  = 'Requete invalide : ' . mysql_error() . "\n";
  	$message .= 'Requete complete : ' . $query;
  	die($message);
  }
bad01aa4   kevin   modification dans...
26
  	
ec9f5496   Jean Wasilewski   Added add element...
27
28
29
  while ($row = mysql_fetch_assoc($resultat)) {
  	echo '<div class="panel panel-default">';
  	echo '<div class="panel-heading">';
9f477c3a   Jean Wasilewski   News editing
30
31
  	echo '<h3 class="panel-title">'.$row['title'];
  	if(isset($_SESSION["admin"])&&$_SESSION["admin"])
1a8cdeb2   Jean Wasilewski   Minor fix 3
32
  		echo ' <a href="#" onclick="editNews('.$row["pk"].')" class="glyphicon glyphicon-pencil"></a>';
9f477c3a   Jean Wasilewski   News editing
33
  	echo '</h3>';
ec9f5496   Jean Wasilewski   Added add element...
34
35
36
37
38
  	echo '</div>';
  	echo '<div class="panel-body">';
  	echo '<p>'.$row['content'].'</p>';
  	echo '</div>';
  	echo '<div class="panel-footer">';
006420a6   Jean Wasilewski   Added date to news
39
  	echo '<p>'.$row['userName'].', le '.$row['created'].'</p>';
ec9f5496   Jean Wasilewski   Added add element...
40
41
  	echo '</div></div>';
  }
bad01aa4   kevin   modification dans...
42
  	
ec9f5496   Jean Wasilewski   Added add element...
43
44
  //On libere l'espace de resultat
  mysql_close($link);
bad01aa4   kevin   modification dans...
45
  ?>
db8bf362   kevin   modif sur news.php