Bonjour, je cherche à mettre le résultat de ma requête dans un tableau HTML, mais j'ai un soucis:
Lorsque je fais la requête, voici le résultat qu'il m'affiche pour toutes les colonnes à afficher:

Notice: Undefined offset: 0 in C:\wamp\www\etopaf driling international\admin\liste_message_clients.php on line 64.
Undefined offset: 1 in C:\wamp\www\etopaf driling international\admin\liste_message_clients.php on line 67.
...
Pourtant j'ai jusqu'à 7 colonnes à afficher.

Voici le code:
Code : Sélectionner tout - Visualiser dans une fenêtre à part
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
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
 
<?php REQUIRE_ONCE('config_bd_etopaf.php'); 
        error_reporting(E_ALL);
	    ini_set('display_errors', TRUE);
		ini_set('display_startup_errors', TRUE);    
?>
<!DOCTYPE html>
    <html>
	    <head>
		    <meta charset="utf-8" />
			<title>les messages clients</title>
			<link rel="stylesheet" href="structure.css" />
			<link rel="stylesheet" href="sogim.css" />
			<link rel="stylesheet" href="art_special.css" />
			<link rel="stylesheet" href="css/bootstrap.min.css" />
		    <link rel="stylesheet" href="css/bootstrap-theme.min.css"/>
		</head>
 
		    <body>
				<div id="bloc_page">
                            <?php // include('entete.php') ?>				
				    <section class="row">
						<article class="article_special" align="center" class="col-md-12 col-sm-12 col-xm-12">
						    <center><h1>LISTE DES MESSAGES DES CLIENTS</h1></center>
						    <table border="1px"; width="200px"; height="500px"; border="1" color="#999"; align="center">
						        <tr> 
								    <td><strong>Numero</strong></td>
									<td><strong>Noms</strong></td>
									<td><strong>Email</strong></td>
									<td><strong>Contacts</strong></td>
									<td><strong>Sujets</strong></td>
									<td><strong>Messages</strong></td>
									<td><strong>Date d'envoi</strong></td>
								</tr>
							<?php 
							$page = isset($_GET['page']) ? $_GET['page'] : 1;
							$page_offset = ($page - 1) * 30;
							$total ='';
							$pagination ='';
 
							$total_element = $bdd -> query('SELECT * from clients'); 
							$total = $total_element ->rowCount();
							$pagination = $total/30;	
 
							$req = $bdd->query("select * from clients ORDER BY id ASC LIMIT $page_offset, 30");
							 /* var_dump($pagination); */ 
 
								while($donnees = $req -> fetch())
                                                        { 
														    ?>
																<tr>
																	    <td> 
																		    <?php echo $donnees[0]; ?>
																		</td>
																		<td> 
																		    <?php echo $donnees[1]; ?>
																		</td>
																		<td> 
																		    <?php echo $donnees[2]; ?>
																		</td>
																		<td>
																		    <?php echo $donnees[3]; ?>
																		</td>
																		<td>
																		    <?php echo $donnees[4]; ?>
																		</td> 
																		<td> 
																		    <?php echo $donnees[5]; ?>
																		</td>
 
																		<td> 
																		    <?php echo $donnees[6]; ?>
																		</td>
 
														<?php
														} 
														?>
																</tr>  
																	</table>
														<?php	
															echo '<p align="center">Page : '; //Pour l'affichage, on centre la liste des pages
                                                            for($i=1; $i<=$pagination; $i++) //On fait notre boucle
                                                                {
																	 //On va faire notre condition
																	if($i==$page) //Si il s'agit de la page actuelle...
																		{
																			echo ' [ '.$i.' ] '; 
																		}	
																		else //Sinon...
																			{
																				echo ' <a href="liste_message_clients.php?page='.$i.'">'.$i.'</a> ';
																			}
                                                                }
                                                                echo '</p>';
                                    				            $req -> closeCursor();
							                            ?>
					    </article>						
				    </section>
				</div>
				<div>
				    <footer>
				        <?php // include('new_footer.php'); ?>
				    </footer>
				</div>
			    <script src="js/jquery.js">	</script>
				<script src="js/bootstrap.min.js"></script>
		    </body> 
	</html>
Et voici le code de la connexion à la base de données:

Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
 
try{
			$bdd =new PDO('mysql:host=localhost; dbname=bd_etopaf; charset=utf8', 'root', '');
				// Activation des erreurs PDO
			$bdd->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
				// mode de fetch par défaut : FETCH_ASSOC / FETCH_OBJ / FETCH_BOTH
			$bdd->setAttribute(PDO::ATTR_DEFAULT_FETCH_MODE, PDO::FETCH_ASSOC);
		} 
			catch(PDOException $e) 
				{
					die('Erreur : ' . $e->getMessage());
				}