Blame view

news.php 1.05 KB
0e66c2eb   Erwan Nanrocki   ajout d un titre h2
1
  <h2> News </h2>
02337ae1   Erwan Nanrocki   correction pour l...
2
  
bad01aa4   kevin   modification dans...
3
  <?php 
db8bf362   kevin   modif sur news.php
4
  	require_once("creds.php");
42f1792e   Jean Wasilewski   Credentials fixed
5
  	$link = mysql_connect(__MYSQL_HOSTNAME__, __MYSQL_USERNAME__, __MYSQL_PASSWORD__)
bad01aa4   kevin   modification dans...
6
  		or die("Impossible de se connecter : " . mysql_error());
1d10adb8   kevin   News.php modif Kevin
7
  	
bad01aa4   kevin   modification dans...
8
  	
db8bf362   kevin   modif sur news.php
9
  	if(!mysql_select_db('crep', $link)){
6c6296ae   kevin   modif news.php kevin
10
  		echo 'Selection de la base de donnees impossible';
db8bf362   kevin   modif sur news.php
11
12
13
  		exit;
  	}
  	
ce5e6320   kevin   News.php modif Kevin
14
  	$requete = "select title, content, users.realname as userName from news, users where news.fk_author=users.pk;";
bad01aa4   kevin   modification dans...
15
16
17
18
  	$resultat = mysql_query($requete);
  	
  	//Pour debugger
  	if (!$resultat) {
6c6296ae   kevin   modif news.php kevin
19
20
  		$message  = 'Requete invalide : ' . mysql_error() . "\n";
  		$message .= 'Requete complete : ' . $query;
bad01aa4   kevin   modification dans...
21
22
23
24
  		die($message);
  	}
  	
  	while ($row = mysql_fetch_assoc($resultat)) {
db8bf362   kevin   modif sur news.php
25
26
27
28
29
30
31
32
33
34
  		echo '<div class="panel panel-default">';
  		echo '<div class="panel-heading">';
  		echo '<h3 class="panel-title">'.$row['title'].'</h3>';
  		echo '</div>';
  		echo '<div class="panel-body">';
  		echo '<p>'.$row['content'].'</p>';
  		echo '</div>';
  		echo '<div class="panel-footer">';
  		echo '<p>'.$row['userName'].'</p>';
  		echo '</div></div>';
bad01aa4   kevin   modification dans...
35
36
  	}
  	
1d10adb8   kevin   News.php modif Kevin
37
  	//On libere l'espace de resultat
bad01aa4   kevin   modification dans...
38
39
  	mysql_close($link);
  ?>
db8bf362   kevin   modif sur news.php