Précédent   Forum des professionnels en informatique > PHP > Langage > Débuter
Débuter Forum d'entraide pour débuter en PHP. Avant de poster -> Cours PHP, FAQ PHP, Outils PHP, etc.
Partagez cette discussion sur d'autres réseaux sociaux : Viadeo Twitter Google Facebook Digg Delicious MySpace Yahoo
Réponse Proposer ce sujet en actualité
 
Outils de la discussion
Publicité
'
Vieux 04/01/2012, 20h41   #1
Nouveau Membre du Club
 
Inscription : décembre 2008
Messages : 258
Détails du profil
Informations personnelles :
Âge : 41
Localisation : France, Var (Provence Alpes Côte d'Azur)

Informations forums :
Inscription : décembre 2008
Messages : 258
Points : 29
Points : 29
Envoyer un message via MSN à xunil2003
Par défaut Array est les variables

Bonjour,

je voudrai modifier un script pour y ajouter mes variables de lecture de la basse de données MySql dans le tableau, je n'y arrive pas.

code original
Code :
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
$comments = array (
	"A"	=>	array( 1 => "Receiver Outlet",
				   2 => "LED Living Room",
				   3 => "Ceiling Fan Light Living Room",
				   4 => "Ceiling Fan Light Living Room",
				   5 => "Ceiling Fan Light Living Room",
				   6 => "Ceiling Fan Light Living Room",
				   7 => "Ceiling Fan Light Living Room",
				   8 => "Ceiling Fan Light Living Room",
				   9 => "Ceiling Fan Light Living Room",
				   10 => "Ceiling Fan Light Living Room",
				   11 => "Ceiling Fan Light Living Room",
				   12 => "Ceiling Fan Light Living Room",
				   13 => "Ceiling Fan Light Living Room",
				   14 => "Ceiling Fan Light Living Room",
				   15 => "Ceiling Fan Light Living Room",
				   16 => "Ceiling Fan Light Living Room",
				 ),
	"D"	=>	array( 1 => " ",
				    2 => "Chaudiere",
				    9 => "Lumière chambre des invités",
				 ),
	"E"	=>	array( 1 => "Lumière bureau",
				    2 => "néon bureau"
				  )
);
Code modifier
Code :
1
2
3
4
5
6
$comments = array (
	"A"	=>	array( 1 => "echo $donnees["nom_module"]",
				   2 => "echo $donnees["nom_module"]"
 
				  )
);
Merci.
__________________
Intel I7 960 | 6 Go Ram | 5 HDD au total 3636 Go | Windows 7 Edition intégral x64 | WampServer 2.0c | Apache 2.2.8 | Php 5.2.6 | MySQL 5.0.51b
xunil2003 est déconnecté   Envoyer un message privé Réponse avec citation 00
Vieux 04/01/2012, 20h54   #2
Membre expérimenté
 
Avatar de amoiraud
 
Homme Adrien
Développeur Web
Inscription : octobre 2006
Messages : 412
Détails du profil
Informations personnelles :
Nom : Homme Adrien
Localisation : France, Rhône (Rhône Alpes)

Informations professionnelles :
Activité : Développeur Web
Secteur : High Tech - Multimédia et Internet

Informations forums :
Inscription : octobre 2006
Messages : 412
Points : 537
Points : 537
Envoyer un message via MSN à amoiraud
Salut,

Pourquoi tu fait un echo ?
Si tu veut mettre tes variables dans le tableau fait juste ca :

Code :
1
2
3
4
5
6
7
 
$comments = array (
	"A"	=>	array( 1 => $donnees["nom_module"],
				 2 => $donnees["nom_module"]
 
			       )
);
amoiraud est déconnecté   Envoyer un message privé Réponse avec citation 00
Vieux 04/01/2012, 23h40   #3
Nouveau Membre du Club
 
Inscription : décembre 2008
Messages : 258
Détails du profil
Informations personnelles :
Âge : 41
Localisation : France, Var (Provence Alpes Côte d'Azur)

Informations forums :
Inscription : décembre 2008
Messages : 258
Points : 29
Points : 29
Envoyer un message via MSN à xunil2003
Bonsoir,

y a t'il un autre moyen pour afficher le contenu de la basse de donner afin d'éviter de faire 256 copier coller .
Merci.

Code :
1
2
3
4
5
6
7
8
9
10
 
$requete_nom_module_1 = mysql_query(" SELECT $nom_colonne FROM $nom_table WHERE id='1' "); // Requête SQL 2
$donnees_nom_module_1 = mysql_fetch_assoc($requete_nom_module_1); // liste ce que contient la table
$requete_nom_module_2 = mysql_query(" SELECT $nom_colonne FROM $nom_table WHERE id='2' "); // Requête SQL 2
$donnees_nom_module_2 = mysql_fetch_assoc($requete_nom_module_2); // liste ce que contient la table
$requete_nom_module_3 = mysql_query(" SELECT $nom_colonne FROM $nom_table WHERE id='3' "); // Requête SQL 2
$donnees_nom_module_3 = mysql_fetch_assoc($requete_nom_module_3); // liste ce que contient la table
$requete_nom_module_4 = mysql_query(" SELECT $nom_colonne FROM $nom_table WHERE id='4' "); // Requête SQL 2
$donnees_nom_module_4 = mysql_fetch_assoc($requete_nom_module_4); // liste ce que contient la table
jusqu'au 256 em modules
Code :
1
2
3
4
5
6
$comments = array (
	"A"	=>	array( 1 => $donnees_nom_module_1["nom_module"],
				   2 => $donnees_nom_module_2["nom_module"]
                                   3 => $donnees_nom_module_3["nom_module"]
                                   4 => $donnees_nom_module_4["nom_module"]
                                   jusqu'au 256 em modules
__________________
Intel I7 960 | 6 Go Ram | 5 HDD au total 3636 Go | Windows 7 Edition intégral x64 | WampServer 2.0c | Apache 2.2.8 | Php 5.2.6 | MySQL 5.0.51b
xunil2003 est déconnecté   Envoyer un message privé Réponse avec citation 00
Vieux 04/01/2012, 23h53   #4
Membre expérimenté
 
Avatar de amoiraud
 
Homme Adrien
Développeur Web
Inscription : octobre 2006
Messages : 412
Détails du profil
Informations personnelles :
Nom : Homme Adrien
Localisation : France, Rhône (Rhône Alpes)

Informations professionnelles :
Activité : Développeur Web
Secteur : High Tech - Multimédia et Internet

Informations forums :
Inscription : octobre 2006
Messages : 412
Points : 537
Points : 537
Envoyer un message via MSN à amoiraud
Salut,

Utilise un tableau et tu fais ca dans une boucle :

Code :
1
2
3
4
5
6
7
 
for ($i = 1; $i <= 256; $i++) {
  $requete_nom_module[$i] = mysql_query(" SELECT $nom_colonne FROM $nom_table WHERE id='" . $i . "' "); // Requête SQL 2
  $donnees_nom_module[$i] = mysql_fetch_assoc($requete_nom_module[$i]); // liste ce que contient la table
 
  $comment['A'][$i] = $donnees_nom_module[$i]['nom_module'];
}
amoiraud est déconnecté   Envoyer un message privé Réponse avec citation 00
Vieux 05/01/2012, 00h16   #5
Nouveau Membre du Club
 
Inscription : décembre 2008
Messages : 258
Détails du profil
Informations personnelles :
Âge : 41
Localisation : France, Var (Provence Alpes Côte d'Azur)

Informations forums :
Inscription : décembre 2008
Messages : 258
Points : 29
Points : 29
Envoyer un message via MSN à xunil2003
bonsoir,

je n'y arrive pas dans le tableau, il y a un counter de 16 lignes pour le code unité (de 1 à 16) avec un bouton qui permet changer de code maison (code maison de A à P) avec le bouton change.
Pour les modules il y a le code maison de A à P et le code unité de 1 a 16, en tout 256 modules de A1 à P16.
dans ma basse de donnée il y a 256 nom de modules dans la colone nom_module, id:1 = A1 - id:256 =P16
je met le code entier sans le css.
Merci.

Code :
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
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
 
<?php 
 
// This is the location of bottlerocket
$brloc="/usr/bin/cm15";
 
// Show debugging info, including command line and output.  Turn off if you need pretty output
$debug=1;
 
// This is the section where you can define home codes and their associated modules.
// Nom des Modules
$comments = array (
	"A"	=>	array( 1 => "Receiver Outlet",
				   2 => "LED Living Room",
				   3 => "Ceiling Fan Light Living Room",
				   4 => "Ceiling Fan Light Living Room",
				   5 => "Ceiling Fan Light Living Room",
				   6 => "Ceiling Fan Light Living Room",
				   7 => "Ceiling Fan Light Living Room",
				   8 => "Ceiling Fan Light Living Room",
				   9 => "Ceiling Fan Light Living Room",
				   10 => "Ceiling Fan Light Living Room",
				   11 => "Ceiling Fan Light Living Room",
				   12 => "Ceiling Fan Light Living Room",
				   13 => "Ceiling Fan Light Living Room",
				   14 => "Ceiling Fan Light Living Room",
				   15 => "Ceiling Fan Light Living Room",
				   16 => "Ceiling Fan Light Living Room",
				 ),
	"D"	=>	array( 1 => " ",
				    2 => "test",
				    9 => "test",
				 ),
	"E"	=>	array( 1 => "test",
				    2 => "test"
				  )
);
// This is not really meant to be user modified - this is the standard X10 home codes
// Though, if you really wanted to, this is defined as:
// "Home Code" => "Display Name"
// Change display name to whatever you want, but don't mess with the home code field.
$hcarray = array ("A"=>"A","B"=>"B","C"=>"C","D"=>"D","E"=>"E","F"=>"F","G"=>"G","H"=>"H","I"=>"I",
				  "J"=>"J","K"=>"K","L"=>"L","M"=>"M","N"=>"N","O"=>"O","P"=>"P");
 
 
 
// Define this script as the actions for POST
$selfscript=$_SERVER['PHP_SELF'];
 
// If we are working with a device number, make sure it's an integer and not a string
if (!empty($_REQUEST[device])) {
	$device=(int)$_REQUEST[device];
}
 
// Process homecode if present in POST, if not, assume first load & 'A'
if (!empty($_REQUEST[homecode])) {
	if (ereg("^[A-P]$",$_REQUEST[homecode])) {
		$homecode=$_REQUEST[homecode];
	} else {
		$inputerr="Erreur: code maison invalide";
	}
} else {
	$homecode='A';
}
 
 
// If we have debug on, then we add some fun output adjustments
if (debug) {
		//$debugcmd=" -vvv ";
		  $debugcmd=" ";
}
 
// DIm POST request
if (!empty($_REQUEST[dimact])) {
	$dim=(int)$_REQUEST[dim];
	if (is_int($device)) {
		$cmddev=$device;
	} else {
		$inputerr="Erreur: code unité invalide ";
	}
	//$cmdline=stripslashes(strip_tags(escapeshellcmd("$brloc $debugcmd --house=$homecode --dim=$dim,$device")));
        $cmdline=stripslashes(strip_tags(escapeshellcmd("$brloc $debugcmd $homecode$device dim $dim")));
}
 
//Bright POST request
if (!empty($_REQUEST[dimactbri])) {
	$dimbri=(int)$_REQUEST[dim];
	if (is_int($device)) {
		$cmddev=$device;
	} else {
		$inputerr="Erreur: code unité invalide ";
	}
	//$cmdline=stripslashes(strip_tags(escapeshellcmd("$brloc $debugcmd --house=$homecode --dim=$dim,$device")));
        $cmdline=stripslashes(strip_tags(escapeshellcmd("$brloc $debugcmd $homecode$device bri $dimbri")));
}
 
// Device/Lamp On/Off POST request
if (!empty($_REQUEST[action])) {
	$action=$_REQUEST[action];
	unset($dim);
	unset($cmdline);
	if ($action == "On") {
		//$cmdact=" --on=";
		$cmdact=" on";
	} elseif($action == "Off") {
		//$cmdact=" --off=";
		$cmdact=" off";
	} else {
		$inputerr="Erreur: Action on off invalide";
	}
	if (is_int($device)) {
		$cmddev=$device;
	} else {
		$inputerr="Erreur: code unité invalide";
	}
	//$cmdline=stripslashes(strip_tags(escapeshellcmd("$brloc $debugcmd --house=$homecode $cmdact$cmddev")));
          $cmdline=stripslashes(strip_tags(escapeshellcmd("$brloc $debugcmd $homecode$cmddev $cmdact")));
}
 
// All Lights On/Off POST Request
if (!empty($_REQUEST[AllLight])) {
	unset($cmdline);
	unset($cmdact);
	$alllight=$_REQUEST[AllLight];
	if ($alllight == "On") {
		$cmdact=" --lamps_on";
	} elseif ($alllight == "Off") {
		$cmdact=" --lamps_off";
	} else {
		$inputerr="Error: Invalid action";
	}
	$cmdline=stripslashes(strip_tags(escapeshellcmd("$brloc $debugcmd --house=$homecode $cmdact")));
}
 
// All Devices On/Off POST Request
if (!empty($_REQUEST[AllDevice])) {
	unset($cmdline);
	unset($cmdact);
	$alllight=$_REQUEST[AllDevice];
	if ($alllight == "On") {
		$cmdact=" --ON";
	} elseif ($alllight == "Off") {
		$cmdact=" --OFF";
	} else {
		$inputerr="Erreur: action all on off invalide";
	}
	$cmdline=stripslashes(strip_tags(escapeshellcmd("$brloc $debugcmd --house=$homecode $cmdact")));
}
 
 
// If we have some error, set tilt, and display error
if (!empty($inputerr)) {
	echo "<span class=\"error\">$inputerr</span><br \>\n";
	$tilt=1;
	//exit(1);
}
 
// Run the actual command and put the output into $output so if we
// are in debug mode, we can do something with it.  Don't run the command
// if we see that the tilt bit is set.
if (!empty($cmdline) && empty($tilt)) {
	exec("$cmdline", $output);
}
?>
<span class="header"><?php echo "X10 Controlleur"; ?></span><br />
<table width="90%" border="0" cellpadding="0" cellspacing="0">
  <tr>
    <td colspan="3" valign="middle" class="noborder4"><form id="homecode" name="homecode" method="post" action="<?php echo $selfscript; ?>">
        <label><span class="listitem">Code maison</span><span class="listitem">
        <select name="homecode">
        <?php foreach ($hcarray as $hcvalue => $hcname) {
   			if ($hcvalue == $homecode) {
				echo "<option value=\"$hcvalue\" selected=\"selected\">$hcname</option>\n";
			} else {
		    	echo "<option value=\"$hcvalue\">$hcname</option>\n";
			}
		}
   		?>
        </select>
        </span></label>
        <span class="listitem">
        <input name="Change" type="submit" id="Change" value="change" />
        </span>
      </form></td>
    <td valign="middle" class="listitem"><form id="all" name="all" method="post" action="<?php echo $selfscript; ?>">
        <input name="homecode" type="hidden" value="<?php echo $homecode ?>" />
        All Lamps:
        <input name="AllLight" type="submit" id="LOn" value="On" />
        <input name="AllLight" type="submit" id="LOff" value="Off" />
        &nbsp;&nbsp;&nbsp;&nbsp; All Devices:
        <input name="AllDevice" type="submit" id="AllDevice" value="On" />
        <input name="AllDevice" type="submit" id="AllDevice" value="Off" />
      </form>
      </td>
  </tr>
  <tr>
    <th width="50%" class="noborder2" scope="col">Commentaire</th>
    <th width="10%" class="noborder2" scope="col">C.M.U</th>
    <th width="10%" class="noborder2" scope="col">Action </th>
    <th width="10%" class="noborder2" scope="col" >+    -</th>
  </tr>
  <?php 
 
    for ( $counter = 1; $counter <= 16; $counter++ ) {
 
   echo "<tr><td class=\"noborder3r\"><span class=\"listitem\"><div>".$comments[$homecode][$counter]."</div></span></td>\n";             
		echo "<td class=\"noborder2r\"><span class=\"listitem\"><div align=\"center\"> $homecode $counter </div></span></td>\n";
		echo "<td class=\"noborder2r\"<form id=\"$counter\" name=\"$counter\" method=\"post\" action=\"$selfscript\">\n";
                echo "<input name=\"device\" type=\"hidden\" value=\"$counter\" />\n";
		echo "<input name=\"homecode\" type=\"hidden\" value=\"$homecode\" />\n";
		echo "<span class=\"listitem\"><div align=\"center\"><input name=\"action\" type=\"submit\" id=\"action\" value=\"On\" />\n";
		echo "<input name=\"action\" type=\"submit\" id=\"action\" value=\"Off\" /></div></span></td>\n";
                echo "<td class=\"noborder2r\"><span class=\"listitem\"> \n";
		echo "<span class=\"dimlist\"><select name=\"dim\">\n";
 
 
		for ( $dimctr = "0"; $dimctr <=  "50"; $dimctr++) {
			selected=\"selected\">".$dimctr."</option>\n";
 
			if ( $dimctr == '0') {
				echo "<option value=\" $dimctr\" selected=\"selected\"> $dimctr</option>\n";
			} else {
				echo "<option value=\" $dimctr\"> $dimctr</option>\n";
			}
		}
 
		echo "<input name=\"dimact\" type=\"submit\" id=\"action\"value=\"Dim\" />";
		echo "<input name=\"dimactbri\" type=\"submit\" id=\"action\"value=\"Bri\" />";
                echo "</select></span>\n";
		echo "</div></span>\n";
		echo "</form>\n";
echo "</div></td>\n";
 
	}
 
  ?></table>
</p>
 
<?php // Only display this table if we have debug turned on
	if (!empty($debug) && !empty($cmdline)) {
		echo "<p><table width=\"90%\" border=\"1\"><tr><td><span class=\"cmdline\">Commande executé : $cmdline<br />";
		if (is_array($output)) {
			foreach( $output as $lineout){
				echo "$lineout <br />";
			}
		}
	echo "</span></td></tr></table></p>";
}
?>
__________________
Intel I7 960 | 6 Go Ram | 5 HDD au total 3636 Go | Windows 7 Edition intégral x64 | WampServer 2.0c | Apache 2.2.8 | Php 5.2.6 | MySQL 5.0.51b
xunil2003 est déconnecté   Envoyer un message privé Réponse avec citation 00
Vieux 05/01/2012, 14h50   #6
Nouveau Membre du Club
 
Inscription : décembre 2008
Messages : 258
Détails du profil
Informations personnelles :
Âge : 41
Localisation : France, Var (Provence Alpes Côte d'Azur)

Informations forums :
Inscription : décembre 2008
Messages : 258
Points : 29
Points : 29
Envoyer un message via MSN à xunil2003
Bonjour,


Le probleme est qu'il ne comprend pas lorsque l'utilisateur change de code maison.
Quand je change le code maison sur B il ne comprend pas qu'il doit lire la basse de donnée a partir de l'id=17 et pour C à partir de l'id=33 etc.. de 16 en 16.
Merci.


Code :
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
 
for ( $counter = 1; $counter <= 16; $counter++ ) {
//for ($i = 1; $i <= 16; $i++) {
  $requete_nom_module[$counter] = mysql_query(" SELECT $nom_colonne FROM $nom_table WHERE id='" . $counter . "' "); // Requête SQL 2
  $donnees_nom_module[$counter] = mysql_fetch_assoc($requete_nom_module[$counter]); // liste ce que contient la table
 
   echo "<tr><td class=\"noborder3r\"><span class=\"listitem\"><div>".$comment['A'][$counter] = $donnees_nom_module[$counter]['nom_module']
."</div></span></td>\n";             
		 echo "<td class=\"noborder2r\"><span class=\"listitem\"><div align=\"center\"> $homecode $counter </div></span></td>\n";
		echo "<td class=\"noborder2r\"<form id=\"$counter\" name=\"$counter\" method=\"post\" action=\"$selfscript\">\n";		
                echo "<input name=\"device\" type=\"hidden\" value=\"$counter\" />\n";
		echo "<input name=\"homecode\" type=\"hidden\" value=\"$homecode\" />\n";
		echo "<span class=\"listitem\"><div align=\"center\"><input name=\"action\" type=\"submit\" id=\"action\" value=\"On\" />\n";
		echo "<input name=\"action\" type=\"submit\" id=\"action\" value=\"Off\" /></div></span></td>\n";
                echo "<td class=\"noborder2r\"><span class=\"listitem\"> \n";
 
		for ( $dimctr = "0"; $dimctr <=  "50"; $dimctr++) {
				selected=\"selected\">".$dimctr."</option>\n";
			if ( $dimctr == '0') {
				echo "<option value=\" $dimctr\" selected=\"selected\"> $dimctr</option>\n";
			} else {
				echo "<option value=\" $dimctr\"> $dimctr</option>\n";
			}
		}
 
		echo "<input name=\"dimact\" type=\"submit\" id=\"action\"value=\"Dim\" />";
		echo "<input name=\"dimactbri\" type=\"submit\" id=\"action\"value=\"Bri\" />";
                echo "</select></span>\n";
		echo "</div></span>\n";
		echo "</form>\n";
 
echo "</div></td>\n";
	}
__________________
Intel I7 960 | 6 Go Ram | 5 HDD au total 3636 Go | Windows 7 Edition intégral x64 | WampServer 2.0c | Apache 2.2.8 | Php 5.2.6 | MySQL 5.0.51b
xunil2003 est déconnecté   Envoyer un message privé Réponse avec citation 00
Vieux 05/01/2012, 15h42   #7
Membre expérimenté
 
Avatar de Torgar
 
Homme Jérémy
Développeur Web
Inscription : août 2007
Messages : 326
Détails du profil
Informations personnelles :
Nom : Homme Jérémy
Âge : 26
Localisation : France, Gard (Languedoc Roussillon)

Informations professionnelles :
Activité : Développeur Web
Secteur : Industrie

Informations forums :
Inscription : août 2007
Messages : 326
Points : 535
Points : 535
Envoyer un message via MSN à Torgar Envoyer un message via Skype™ à Torgar
Citation:
Envoyé par xunil2003 Voir le message
Bonjour,


Le probleme est qu'il ne comprend pas lorsque l'utilisateur change de code maison.
Quand je change le code maison sur B il ne comprend pas qu'il doit lire la basse de donnée a partir de l'id=17 et pour C à partir de l'id=33 etc.. de 16 en 16.
Merci.


Code :
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
 
for ( $counter = 1; $counter <= 16; $counter++ ) {
//for ($i = 1; $i <= 16; $i++) {
  $requete_nom_module[$counter] = mysql_query(" SELECT $nom_colonne FROM $nom_table WHERE id='" . $counter . "' "); // Requête SQL 2
  $donnees_nom_module[$counter] = mysql_fetch_assoc($requete_nom_module[$counter]); // liste ce que contient la table
 
   echo "<tr><td class=\"noborder3r\"><span class=\"listitem\"><div>".$comment['A'][$counter] = $donnees_nom_module[$counter]['nom_module']
."</div></span></td>\n";             
         echo "<td class=\"noborder2r\"><span class=\"listitem\"><div align=\"center\"> $homecode $counter </div></span></td>\n";
        echo "<td class=\"noborder2r\"<form id=\"$counter\" name=\"$counter\" method=\"post\" action=\"$selfscript\">\n";        
                echo "<input name=\"device\" type=\"hidden\" value=\"$counter\" />\n";
        echo "<input name=\"homecode\" type=\"hidden\" value=\"$homecode\" />\n";
        echo "<span class=\"listitem\"><div align=\"center\"><input name=\"action\" type=\"submit\" id=\"action\" value=\"On\" />\n";
        echo "<input name=\"action\" type=\"submit\" id=\"action\" value=\"Off\" /></div></span></td>\n";
                echo "<td class=\"noborder2r\"><span class=\"listitem\"> \n";
 
        for ( $dimctr = "0"; $dimctr <=  "50"; $dimctr++) {
                selected=\"selected\">".$dimctr."</option>\n";
            if ( $dimctr == '0') {
                echo "<option value=\" $dimctr\" selected=\"selected\"> $dimctr</option>\n";
            } else {
                echo "<option value=\" $dimctr\"> $dimctr</option>\n";
            }
        }
 
        echo "<input name=\"dimact\" type=\"submit\" id=\"action\"value=\"Dim\" />";
        echo "<input name=\"dimactbri\" type=\"submit\" id=\"action\"value=\"Bri\" />";
                echo "</select></span>\n";
        echo "</div></span>\n";
        echo "</form>\n";
 
echo "</div></td>\n";
    }
Il y a une erreur ici :
Code :
selected=\"selected\">".$dimctr."</option>\n";
Cette ligne fait une Parse error. Je te conseille vivement d'activer l'affichage des erreurs via error_reporting(E_ALL); en mode debug. Tu le supprimeras quand tu seras en production.
__________________
Vivez vos rêves !!!

Si vous voulez que l'on vous aide, postez votre code avec la balise [ CODE ] [ /CODE ] (bouton # de l'éditeur)
Torgar est déconnecté   Envoyer un message privé Réponse avec citation 00
Vieux 05/01/2012, 18h40   #8
Nouveau Membre du Club
 
Inscription : décembre 2008
Messages : 258
Détails du profil
Informations personnelles :
Âge : 41
Localisation : France, Var (Provence Alpes Côte d'Azur)

Informations forums :
Inscription : décembre 2008
Messages : 258
Points : 29
Points : 29
Envoyer un message via MSN à xunil2003
bjr,

j'ai trouver c'est bon.
Par contre pour les boutons submit quand je veut insérer le nom des boutons on depuis la basse mysql , j'ai ceci qui s'affiche dans le bouton au lieu de leur nom :
Code :
.Array['nom_commande_On'].
code original
Code :
echo "<span class=\"listitem\"><div align=\"center\"><input name=\"action\" type=\"submit\" id=\"action\" value=\"on\" />\n";
code modifier
Code :
echo "<span class=\"listitem\"><div align=\"center\"><input name=\"action\" type=\"submit\" id=\"action\" value=\".$donnees_nom_bouton_on[$counter]['nom_commande_On'].\" />\n";
Merci.
__________________
Intel I7 960 | 6 Go Ram | 5 HDD au total 3636 Go | Windows 7 Edition intégral x64 | WampServer 2.0c | Apache 2.2.8 | Php 5.2.6 | MySQL 5.0.51b
xunil2003 est déconnecté   Envoyer un message privé Réponse avec citation 00
Vieux 05/01/2012, 19h05   #9
Nouveau Membre du Club
 
Inscription : décembre 2008
Messages : 258
Détails du profil
Informations personnelles :
Âge : 41
Localisation : France, Var (Provence Alpes Côte d'Azur)

Informations forums :
Inscription : décembre 2008
Messages : 258
Points : 29
Points : 29
Envoyer un message via MSN à xunil2003
bonsoir,

j'ai trouvé il faut mettre :

pour le bouton submit:
Code :
echo "<span class=\"listitem\"><div align=\"center\"><input name=\"action\" type=\"submit\" id=\"action\" value=\" ".$donnees_nom_bouton_on[$counter]['nom_commande_On']."\" />\n";
ensuite pour la basse de donnée
Code :
1
2
$requete_nom_bouton_on[$counter] = mysql_query(" SELECT $nom_bouton_on FROM $nom_table WHERE code_maison_unite='" .$homecode."". $counter. "' "); // Requête SQL 2
$donnees_nom_bouton_on[$counter] = mysql_fetch_assoc($requete_nom_bouton_on[$counter]); // liste ce que contient la table
merci.
__________________
Intel I7 960 | 6 Go Ram | 5 HDD au total 3636 Go | Windows 7 Edition intégral x64 | WampServer 2.0c | Apache 2.2.8 | Php 5.2.6 | MySQL 5.0.51b
xunil2003 est déconnecté   Envoyer un message privé Réponse avec citation 00
Vieux 06/01/2012, 13h43   #10
Nouveau Membre du Club
 
Inscription : décembre 2008
Messages : 258
Détails du profil
Informations personnelles :
Âge : 41
Localisation : France, Var (Provence Alpes Côte d'Azur)

Informations forums :
Inscription : décembre 2008
Messages : 258
Points : 29
Points : 29
Envoyer un message via MSN à xunil2003
bonjour,

Pour que le bouton submit affiche marche ou allumer selon ce qui est enregistré dans la basse de donnée Mysql, j'ai m'y ceci:
Code :
1
2
code bouton submit
echo "<span class=\"listitem\"><div align=\"center\"><input name=\"action\" type=\"submit\" id=\"action\" value=\" ".$donnees_nom_bouton_on[$counter]['nom_commande_On']."\" />\n";
est pour le post
Code :
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
// Device/Lamp On POST request
if (!empty($_REQUEST[action])) {
	$action=$_REQUEST[action];
	unset($dim);
	unset($cmdline);
	if ($action == "Allumer") {
		$cmdact=" on";
	} elseif($action == "Marche") {
		$cmdact=" on";
	} else {
		$inputerr="Erreur: Action on off invalide";
	}
	if (is_int($device)) {
		$cmddev=$device;
	} else {
		$inputerr="Erreur: code unité invalide";
	}
	//$cmdline=stripslashes(strip_tags(escapeshellcmd("$brloc $debugcmd --house=$homecode $cmdact$cmddev")));
          $cmdline=stripslashes(strip_tags(escapeshellcmd("$brloc $debugcmd $homecode$cmddev $cmdact")));
}
le problème est que allumer ne fonctionne pas, il m'affiche
Code :
Erreur: Action on off invalide
par contre quand je le met en dur ca marche , comme ceci
Code :
echo "<span class=\"listitem\"><div align=\"center\"><input name=\"action\" type=\"submit\" id=\"action\" value=\" Allumer" />\n";
Pourquoi ?
Comment puis je faire

Merci.
__________________
Intel I7 960 | 6 Go Ram | 5 HDD au total 3636 Go | Windows 7 Edition intégral x64 | WampServer 2.0c | Apache 2.2.8 | Php 5.2.6 | MySQL 5.0.51b
xunil2003 est déconnecté   Envoyer un message privé Réponse avec citation 00
Vieux 06/01/2012, 14h24   #11
Membre expérimenté
 
Avatar de amoiraud
 
Homme Adrien
Développeur Web
Inscription : octobre 2006
Messages : 412
Détails du profil
Informations personnelles :
Nom : Homme Adrien
Localisation : France, Rhône (Rhône Alpes)

Informations professionnelles :
Activité : Développeur Web
Secteur : High Tech - Multimédia et Internet

Informations forums :
Inscription : octobre 2006
Messages : 412
Points : 537
Points : 537
Envoyer un message via MSN à amoiraud
Quand tu fait un print de $action il t'affiche quoi ?
amoiraud est déconnecté   Envoyer un message privé Réponse avec citation 00
Vieux 06/01/2012, 14h28   #12
Membre expérimenté
 
Avatar de Torgar
 
Homme Jérémy
Développeur Web
Inscription : août 2007
Messages : 326
Détails du profil
Informations personnelles :
Nom : Homme Jérémy
Âge : 26
Localisation : France, Gard (Languedoc Roussillon)

Informations professionnelles :
Activité : Développeur Web
Secteur : Industrie

Informations forums :
Inscription : août 2007
Messages : 326
Points : 535
Points : 535
Envoyer un message via MSN à Torgar Envoyer un message via Skype™ à Torgar
Bonjour,

$_REQUEST[action] c'est terminé cette notation, utilise plutôt $_POST['action']Cette remarque vaut pour tout le code pas uniquement pour cette variable.

Fait un var_dump($_POST['action']); et dit nous ce que ça donne.

A mon avis, ta variable est vide...
__________________
Vivez vos rêves !!!

Si vous voulez que l'on vous aide, postez votre code avec la balise [ CODE ] [ /CODE ] (bouton # de l'éditeur)
Torgar est déconnecté   Envoyer un message privé Réponse avec citation 00
Vieux 06/01/2012, 15h06   #13
Nouveau Membre du Club
 
Inscription : décembre 2008
Messages : 258
Détails du profil
Informations personnelles :
Âge : 41
Localisation : France, Var (Provence Alpes Côte d'Azur)

Informations forums :
Inscription : décembre 2008
Messages : 258
Points : 29
Points : 29
Envoyer un message via MSN à xunil2003
bjr,

j'avai dèja fait le test pour $actionil m'affiche bien "Allumer"

j'ai remplacé
Code :
if (!empty($_REQUEST[dimactbri])) {
par
Code :
if (var_dump( $_POST['action'] )) {
il m'affiche
Code :
string(8) " Allumer" Erreur: Action on off invalide
Merci.
__________________
Intel I7 960 | 6 Go Ram | 5 HDD au total 3636 Go | Windows 7 Edition intégral x64 | WampServer 2.0c | Apache 2.2.8 | Php 5.2.6 | MySQL 5.0.51b
xunil2003 est déconnecté   Envoyer un message privé Réponse avec citation 00
Vieux 06/01/2012, 15h11   #14
Membre expérimenté
 
Avatar de Torgar
 
Homme Jérémy
Développeur Web
Inscription : août 2007
Messages : 326
Détails du profil
Informations personnelles :
Nom : Homme Jérémy
Âge : 26
Localisation : France, Gard (Languedoc Roussillon)

Informations professionnelles :
Activité : Développeur Web
Secteur : Industrie

Informations forums :
Inscription : août 2007
Messages : 326
Points : 535
Points : 535
Envoyer un message via MSN à Torgar Envoyer un message via Skype™ à Torgar
Code :
string(8) " Allumer" Erreur: Action on off invalide
Tu en profiteras pour supprimer cet espace en trop dans la chaîne.....

Code :
echo "<span class=\"listitem\"><div align=\"center\"><input name=\"action\" type=\"submit\" id=\"action\" value=\"".$donnees_nom_bouton_on[$counter]['nom_commande_On']."\" />\n";
Et enfin, mettre le var_dump() dans une condition était inutile ^^
__________________
Vivez vos rêves !!!

Si vous voulez que l'on vous aide, postez votre code avec la balise [ CODE ] [ /CODE ] (bouton # de l'éditeur)
Torgar est déconnecté   Envoyer un message privé Réponse avec citation 00
Vieux 06/01/2012, 15h48   #15
Nouveau Membre du Club
 
Inscription : décembre 2008
Messages : 258
Détails du profil
Informations personnelles :
Âge : 41
Localisation : France, Var (Provence Alpes Côte d'Azur)

Informations forums :
Inscription : décembre 2008
Messages : 258
Points : 29
Points : 29
Envoyer un message via MSN à xunil2003
re,

j'ai remplacer
Code :
1
2
if (!empty($_REQUEST[action])) {
	$action=$_REQUEST[action];
par
Code :
1
2
if (isset($_POST['action'])) {
	$action=$_POST[action];
Code :
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
if (isset($_POST['action'])) {
	$action=$_POST[action];
	unset($dim);
	unset($cmdline);
	if ($action == "Allumer") {
		$cmdact=" on";
	} elseif($action == "Marche") {
		$cmdact=" on";
	} else {
		$inputerr="Erreur: Action on off invalide";
	}
	if (is_int($device)) {
		$cmddev=$device;
	} else {
		$inputerr="Erreur: code unité invalide";
	}
	//$cmdline=stripslashes(strip_tags(escapeshellcmd("$brloc $debugcmd --house=$homecode $cmdact$cmddev")));
          $cmdline=stripslashes(strip_tags(escapeshellcmd("$brloc $debugcmd $homecode$cmddev $cmdact")));
}
 
var_dump($_POST['action']);
Si je supprime cette ligne je n'ai plus le bouton allumer qui s'affiche
Code :
echo "<span class=\"listitem\"><div align=\"center\"><input name=\"action\" type=\"submit\" id=\"action\" value=\"".$donnees_nom_bouton_on[$counter]['nom_commande_On']."\" />\n";
var_dump() m'affiche toujours la même chose
Code :
string(8) " Allumer" Erreur: Action on off invalide
Merci
__________________
Intel I7 960 | 6 Go Ram | 5 HDD au total 3636 Go | Windows 7 Edition intégral x64 | WampServer 2.0c | Apache 2.2.8 | Php 5.2.6 | MySQL 5.0.51b
xunil2003 est déconnecté   Envoyer un message privé Réponse avec citation 00
Vieux 06/01/2012, 16h06   #16
Membre expérimenté
 
Avatar de Torgar
 
Homme Jérémy
Développeur Web
Inscription : août 2007
Messages : 326
Détails du profil
Informations personnelles :
Nom : Homme Jérémy
Âge : 26
Localisation : France, Gard (Languedoc Roussillon)

Informations professionnelles :
Activité : Développeur Web
Secteur : Industrie

Informations forums :
Inscription : août 2007
Messages : 326
Points : 535
Points : 535
Envoyer un message via MSN à Torgar Envoyer un message via Skype™ à Torgar
Si tu avais pris le temps de bien lire et de comparer mon code avec le tien, tu te serais rendu compte qu'il y a un espace ici : value=\" ".$donnees_nom_bouton. A aucun moment je t'ai dit de supprimer la ligne

Et puis, même si ça fonctionne, je t'ai dit de rajouter des simples quote pour entourer le nom de la variable $_POST['action'] !!!

Tu verras qu'en supprimant l'espace (et non la ligne !), ta condition if ($action == "Allumer") { sera juste !
__________________
Vivez vos rêves !!!

Si vous voulez que l'on vous aide, postez votre code avec la balise [ CODE ] [ /CODE ] (bouton # de l'éditeur)
Torgar est déconnecté   Envoyer un message privé Réponse avec citation 00
Vieux 07/01/2012, 11h57   #17
Nouveau Membre du Club
 
Inscription : décembre 2008
Messages : 258
Détails du profil
Informations personnelles :
Âge : 41
Localisation : France, Var (Provence Alpes Côte d'Azur)

Informations forums :
Inscription : décembre 2008
Messages : 258
Points : 29
Points : 29
Envoyer un message via MSN à xunil2003
bjr,

il est vrai que je n'ai pas fait attention a l'espace

Merci
__________________
Intel I7 960 | 6 Go Ram | 5 HDD au total 3636 Go | Windows 7 Edition intégral x64 | WampServer 2.0c | Apache 2.2.8 | Php 5.2.6 | MySQL 5.0.51b
xunil2003 est déconnecté   Envoyer un message privé Réponse avec citation 00
Réponse Proposer ce sujet en actualité Cette discussion est résolue.
Outils de la discussion



Fuseau horaire GMT +2. Il est actuellement 04h06.


 
 
 
 
Partenaires

Hébergement Web