-
Notifications
You must be signed in to change notification settings - Fork 0
/
index1.php
40 lines (39 loc) · 1.13 KB
/
index1.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
<!DOCTYPE html>
<html>
<head>
<title>Affichage des articles</title>
<link rel="stylesheet" type="text/css" href="styles.css">
</head>
<body>
<h1>Liste des articles</h1>
<table>
<tr>
<th>Titre</th>
<th>Contenu</th>
<th>Catégorie</th>
</tr>
<?php
$servername = "localhost";
$username = "root";
$password = "";
$dbname = "mglsi_news";
$conn = new mysqli($servername, $username, $password, $dbname);
if ($conn->connect_error) {
die("Connection echoué: " . $conn->connect_error);
}
$sql = "SELECT a.titre, a.contenu, c.libelle AS categorie
FROM Article a
INNER JOIN Categorie c ON a.categorie = c.id";
$result = $conn->query($sql);
if ($result->num_rows > 0) {
while($row = $result->fetch_assoc()) {
echo "<tr><td>".$row["titre"]."</td><td>".$row["contenu"]."</td><td>".$row["categorie"]."</td></tr>";
}
} else {
echo "Zéro resultats";
}
$conn->close();
?>
</table>
</body>
</html>