-
Notifications
You must be signed in to change notification settings - Fork 0
/
select_from.php
67 lines (63 loc) · 1.52 KB
/
select_from.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
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
<!DOCTYPE html>
<html>
<head>
<title>Accès base de données</title>
<meta charset="utf-8">
<link rel="stylesheet" href="cours.css">
</head>
<?php
include 'header.php';
?>
<body>
<div class="P3">
<h2>Renseignements</h2>
<?php
$servername = 'localhost';
$dbname= 'mabase';
$username = 'root';
$password = '';
try{
$dbco = new PDO("mysql:host=$servername;dbname=$dbname", $username, $password);
$dbco->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
$sth = $dbco->prepare("SELECT * FROM Renseignements ORDER BY User_name ASC ");
$sth->execute();
$NbreData = $sth->rowCount();
$rowAll = $sth->fetchAll();
}
catch(PDOException $e){
echo "Erreur : " . $e->getMessage();
}
if ($NbreData != 0)
{
?>
<table class="result1">
<thead>
<tr>
<th>Nom</th>
<th>Prénom</th>
<th>Mail</th>
<th>Téléphone</th>
<th>Message</th>
</tr>
</thead>
<?php
}
foreach($rowAll as $row) {
?>
<tr class="result2">
<td><?php echo $row['User_name']; ?></td>
<td><?php echo $row['User_firstname']; ?></td>
<td><?php echo $row['User_mail']; ?></td>
<td><?php echo $row['User_phone']; ?></td>
<td><?php echo $row['User_message']; ?></td>
</tr>
</div>
<?php
}
exit ();
?>
</body>
<?php
include 'footer.php';
?>
</html>