Bonjour,
J'ai deux problèmes.
1/ Quand je liste le contenue de ma table (mysql) avec php l'affichage commencce par l'id 2 et non par le 1?
Ai-je fait une erreur ?
php affiche :
table mysql (depuis phpmyadmin) :
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5 Id Utilisateur Conserne Adresse ip Nom poste mot de passe 2 0 0 0 poste12 0 3 poste13 4 poste14
Ma table mysql :
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5 id utilisateur conserne adresse_ip nom_poste mdp 1 0 0 0 poste11 0 2 0 0 0 poste12 0 3 poste13 4 poste14
2/ je voudrai colorier les lignes, toute les 2 lignes
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 -- -- Base de données: `telephonie` -- -- -------------------------------------------------------- -- -- Structure de la table `poste` -- CREATE TABLE IF NOT EXISTS `poste` ( `id` int(11) NOT NULL AUTO_INCREMENT, `utilisateur` varchar(80) NOT NULL, `conserne` varchar(80) NOT NULL, `adresse_ip` varchar(16) NOT NULL, `nom_poste` varchar(20) NOT NULL, `mdp` varchar(20) NOT NULL, KEY `id` (`id`) ) ENGINE=MyISAM DEFAULT CHARSET=latin1 AUTO_INCREMENT=5 ; -- -- Contenu de la table `poste` -- INSERT INTO `poste` (`id`, `utilisateur`, `conserne`, `adresse_ip`, `nom_poste`, `mdp`) VALUES (1, '0', '0', '0', 'poste11', '0'), (2, '0', '0', '0', 'poste12', '0'), (3, '', '', '', 'poste13', ''), (4, '', '', '', 'poste14', '');
Ou dois-je positionner bgcolors
Le code
Merci.
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 <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" /> <title>Les postes Asterisk</title> <style type="text/css"> <!-- a:link { text-decoration: none; } a:visited { text-decoration: none; } a:hover { text-decoration: underline; } a:active { text-decoration: none; } --> </style></head> <body> <p> <?php include("../N4/template/entete.php"); ?> <?php mysql_connect("localhost", "xxxx", "xxxxxx"); // Connexion à MySQL mysql_select_db("telephonie"); // Sélection de la base de donnée $reponse = mysql_query("SELECT * FROM poste"); // Requête SQL $donnees = mysql_fetch_assoc($reponse); // liste ce que contient la table ?> </p> <p align="center">Les postes Asterisk </p> <table width="2375" border="0"> <tr> <th width="23" bgcolor="#999999" scope="col">Id</th> <th width="152" bgcolor="#999999" scope="col">Utilisateur</th> <th width="98" bgcolor="#999999" scope="col">Conserne </th> <th width="90" bgcolor="#999999" scope="col">Adresse ip</th> <th width="161" bgcolor="#999999" scope="col">Nom poste</th> <th width="348" bgcolor="#999999" scope="col">mot de passe</th> </tr> <tr> <th scope="row"> </th> <td> </td> <td> </td> <td> </td> <td> </td> <td> </td> <td> </td> </tr> <?php // ... Modulos --> initialise $i à 0 $i = 0; $bgcolor = ($i++ & 1) ? '#fff' : '#000'; while ($donnees = mysql_fetch_array($reponse) ) // boucle pour lister tout ce que contient la table : modules_x10 { ?> <tr> <th bgcolor='.$bgcolor.' scope="row"><?php echo $donnees["id"]; ?></th> <td bgcolor='.$bgcolor.'><?php echo $donnees["utilisateur"]; ?></td> <td bgcolor="#CCCCCC"><?php echo $donnees["conserne"]; ?></td> <td bgcolor="#CCCCCC"><?php echo $donnees["adresse_ip"]; ?></td> <td bgcolor="#CCCCCC"><?php echo $donnees["nom_poste"]; ?></td> <td bgcolor="#CCCCCC"><?php echo $donnees["mdp"]; ?></td> </tr> <?php } //toute la ligne est comprise dans la boucle while?> </table> <p align="center">[<a href="../N4/index.php">Accueil</a>] - [<a href="../N4/index.php?page=agenda-telephonique">Sommaire</a>] - [<a href="../agenda-telephonique/annuaire-mysql-Insert-une-entree.php">Ajouter</a>] - [<a href="../agenda-telephonique/annuaire-mysql-modifier-une-ligne.php">Modifier</a>] - [<a href="../agenda-telephonique/annuaire-mysql-supprimer-une-ligne-mysql.php">Supprimer</a>] - [<a href="../agenda-telephonique/annuaire-mysql-recherche-des-donnees.php">Rechercher</a>] <?php include('../commun/template/pied.php3'); ?> <td><FORM> <INPUT TYPE="button" VALUE="Retour" onClick="history.back()"> </FORM> </body> </html> <?php mysql_close(); // Fermeture de la connexion Mysql ?>
Partager