Blame view

news.php 1.08 KB
bad01aa4   kevin   modification dans...
1
  <?php 
db8bf362   kevin   modif sur news.php
2
  	require_once("creds.php");
42f1792e   Jean Wasilewski   Credentials fixed
3
  	$link = mysql_connect(__MYSQL_HOSTNAME__, __MYSQL_USERNAME__, __MYSQL_PASSWORD__)
bad01aa4   kevin   modification dans...
4
  		or die("Impossible de se connecter : " . mysql_error());
6c6296ae   kevin   modif news.php kevin
5
  	echo 'Connexion reussie';
bad01aa4   kevin   modification dans...
6
  	
db8bf362   kevin   modif sur news.php
7
  	if(!mysql_select_db('crep', $link)){
6c6296ae   kevin   modif news.php kevin
8
  		echo 'Selection de la base de donnees impossible';
db8bf362   kevin   modif sur news.php
9
10
11
  		exit;
  	}
  	
c8cce969   kevin   News.php modif Kevin
12
  	$requete = "select title, content, user.realname as userName from news, user where news.fk_author=user.pk;";
bad01aa4   kevin   modification dans...
13
14
15
16
  	$resultat = mysql_query($requete);
  	
  	//Pour debugger
  	if (!$resultat) {
6c6296ae   kevin   modif news.php kevin
17
18
  		$message  = 'Requete invalide : ' . mysql_error() . "\n";
  		$message .= 'Requete complete : ' . $query;
bad01aa4   kevin   modification dans...
19
20
21
22
  		die($message);
  	}
  	
  	while ($row = mysql_fetch_assoc($resultat)) {
db8bf362   kevin   modif sur news.php
23
24
25
26
27
28
29
30
31
32
  		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...
33
34
35
36
37
38
  	}
  	
  	//On libere l'espace de resultat.
  	mysql_free_result($result);
  	mysql_close($link);
  ?>
db8bf362   kevin   modif sur news.php