Boucle FOR
4lman78
Messages postés
44
Date d'inscription
jeudi 19 octobre 2006
Statut
Membre
Dernière intervention
9 février 2010
-
15 juin 2009 à 20:25
kohntark
Messages postés
3708
Date d'inscription
lundi 5 juillet 2004
Statut
Membre
Dernière intervention
27 avril 2012
-
15 juin 2009 à 21:51
Comment faire une boucle for avec toute ces variables ?
<?php
$q1 = addslashes($_POST['q1']);
$d1 = stripslashes(utf8_decode($_POST['d1']));
$pu1 = addslashes($_POST['pu1']);
$p1 = addslashes($_POST['p1']);
$s1 = addslashes($_POST['s1']);
for ($i=1; $i<=50; $i++){
if (isset($_POST['t1'.$i])) {
if ($i!=1){
$temp = $temp . " / ";
}
}
$temp = $temp . addslashes($_POST['t1'.$i]);
}
$t1 = $temp;
?>
Pour infos, q1, d1, pu1, p1,s1,t1 se répétera en q2, d2, pu2, p2,s2,t2....et ainsi de suite
j'ai essayé ca :
<?php
for ($j=1; $j<=50; $j++){
$q$j = addslashes($_POST['q'.$j]);
$d$j = stripslashes(utf8_decode($_POST['d'.$j]));
$pu$j = addslashes($_POST['pu'.$j]);
$p$j = addslashes($_POST['p'.$j]);
$s$j = addslashes($_POST['s'.$j]);
for ($i= 1; $i<=50; $i++){
if (isset($_POST['t'.$j.$i])) {
if ($i!=1){
$temp = $temp . " / ";
}
}
$temp = $temp . addslashes($_POST['t'.$j.$i]);
}
$t$j = $temp;
}
?>
Les parties en gras...j'ai un gros doute !