Blame view

news.php 1.06 KB
bad01aa4   kevin   modification dans...
1
  <?php 
db8bf362   kevin   modif sur news.php
2
3
  	require_once("creds.php");
  	$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
12
  		exit;
  	}
  	
  	$requete = "select title content user.name 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