Précédent   Forum des professionnels en informatique > PHP > Langage > Formulaires
Formulaires Forum d'entraide sur les formulaires avec PHP. Avant de poster -> FAQ formulaires, Cours de formulaires et Sources de formulaires
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 07/12/2006, 17h20   #1
Nouveau Membre du Club
 
Inscription : novembre 2005
Messages : 182
Détails du profil
Informations forums :
Inscription : novembre 2005
Messages : 182
Points : 31
Points : 31
Par défaut Boucle et concatenation

bonjour,

A partir d'un formulaire je recupere une ou plusieurs valeurs du meme type :
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
<table border="1" cellspacing="0" cellpadding="0" bordercolor="#DDDDDD"><tr><td>
		<?
		$REQUETE_CAT = "select *";
		$REQUETE_CAT.= " from catalogue";
		//echo $REQUETE;
		$RESULTAT_CAT= mysql_query ($REQUETE_CAT, $CONNEXION);
		while ($PRODUIT= mysql_fetch_array ($RESULTAT_CAT)){
	 		extract ($PRODUIT);
	 		if (ereg("$NOM_CATALOGUE", $CATALOGUE)){
	 	?>
		<table border="0" cellspacing="0" cellpadding="0">
      <tr><td colspan="3" bgcolor="#FFFFFF"><img src="images/blanc.gif" width="1" height="5" /></td></tr>
			<tr>
        <td width="135">&nbsp;<strong>COMMANDE <? echo $NOM_CATALOGUE; ?></strong>&nbsp;:</td>
        <td width="110" align="right">FERME<input type="checkbox" name="FERME_<? echo $NOM_CATALOGUE; ?>" <? if (ereg("FERME", $COMMANDE)){echo "checked=\"checked\"";} else {echo "";} ?> /></td>
        <td>&nbsp;<input name="FERME_REF_<? echo $NOM_CATALOGUE; ?>" type="text" value="<? echo $FERME_REF; ?>" size="8" maxlength="6" /></td>
      </tr>
      <tr>
        <td width="110">&nbsp;</td>
        <td width="110" align="right" valign="top">OPTIONNELLE<input type="checkbox" name="OPTIONNELLE_<? echo $NOM_CATALOGUE; ?>" <? if (ereg("OPTION", $COMMANDE)){echo "checked=\"checked\"";} else {echo "";} ?> /></td>
        <td>&nbsp;<input name="OPTIONNELLE_REF_<? echo $NOM_CATALOGUE; ?>" type="text" value="<? echo $OPTIONNELLE_REF; ?>" size="8" maxlength="6" /></td>
      </tr>
      <tr>
    		<td align="left" valign="top" colspan="3">&nbsp;<strong>DATE DE LIVRAISON&nbsp;:&nbsp;</strong><input name="LIVRAISON_SERPIE_<? echo $NOM_CATALOGUE; ?>" type="text" id="LIVRAISON_SERPIE_<? echo $NOM_CATALOGUE; ?>" value="<? echo dateFormat_affiche($LIVRAISON_SERPIE); ?>" size="8" maxlength="10" onFocus="this.value=''" /></td>
  		</tr>
      <tr><td colspan="3" bgcolor="#FFFFFF"><img src="images/blanc.gif" width="1" height="5" /></td></tr>
    </table>
    <? //} else{ ?>
    <? } } ?>
    </td></tr></table>
en validant le formulaire je recupere ces donnees. Mais ne sachant pas a l'avance le nombre de ligne du meme type je vais recuperer je fais une boucle while.
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
$REQUETE_CAT = "select *";
	$REQUETE_CAT.= " from catalogue";
	echo $REQUETE_CAT."<br /><br />";
	$RESULTAT_CAT= mysql_query ($REQUETE_CAT, $CONNEXION);
 
	while ($PRODUIT= mysql_fetch_array ($RESULTAT_CAT)){
		extract ($PRODUIT);
		if (ereg("$NOM_CATALOGUE", $RECUP_CATALOGUE)){
			$FERME_TEMP= "RECUP_FERME_".$NOM_CATALOGUE;
			$OPTIONNELLE_TEMP= "RECUP_OPTIONNELLE_".$NOM_CATALOGUE;
			//echo "FERME_TEMP : ".$FERME_TEMP."<br />";
			if(isset($$FERME_TEMP)){
				$RECUP_FERME= "FERME";
			}
			else{ $RECUP_FERME= ""; }
			if(isset($$OPTIONNELLE_TEMP)){
				$RECUP_OPTIONNELLE= "OPTION";
			}
			else{ $RECUP_OPTIONNELLE= ""; }
 
			$FERME_REF_TEMP= "RECUP_FERME_REF_".$NOM_CATALOGUE;
			$OPTIONNELLE_REF_TEMP= "RECUP_OPTIONNELLE_REF_".$NOM_CATALOGUE;
			$RECUP_FERME_REF= isset($$FERME_REF_TEMP)?$$FERME_REF_TEMP:"";
			$RECUP_OPTIONNELLE_REF= isset($$OPTIONNELLE_REF_TEMP)?$$OPTIONNELLE_REF_TEMP:"";
			$COMMANDE_TEMP= "COMMANDE_".$NOM_CATALOGUE;
			$$COMMANDE= $NOM_CATALOGUE.":".$RECUP_FERME.$RECUP_FERME_REF."-".$RECUP_OPTIONNELLE.$RECUP_OPTIONNELLE_REF;
			echo $COMMANDE_TEMP." : ".$$COMMANDE."<br />";
 
			$LIVRAISON_SERPIE_TEMP= "RECUP_LIVRAISON_SERPIE_".$NOM_CATALOGUE;
			$RECUP_LIVRAISON_SERPIE= isset($$LIVRAISON_SERPIE_TEMP)?$$LIVRAISON_SERPIE_TEMP:"";
			$LIVRAISON_TEMP= "LIVRAISON_".$NOM_CATALOGUE;
			$$LIVRAISON_SERPIE= $NOM_CATALOGUE.":".$RECUP_LIVRAISON_SERPIE;
			echo $LIVRAISON_TEMP." : ".$$LIVRAISON_SERPIE."<br /><br />";		
		}
	}
Mon but etant de concatener chaque occurence de $$COMMANDE et de $$LIVRAISON_SERPIE.

Sil vous plait, help.
dafalri est déconnecté   Envoyer un message privé Réponse avec citation 00
Vieux 07/12/2006, 17h35   #2
Nouveau Membre du Club
 
Inscription : novembre 2005
Messages : 182
Détails du profil
Informations forums :
Inscription : novembre 2005
Messages : 182
Points : 31
Points : 31
en fait il faudrait que je puisse sortir chaque occurrence de la boucle while et que je puisse ensuite concatener ces occurences
dafalri est déconnecté   Envoyer un message privé Réponse avec citation 00
Vieux 07/12/2006, 19h22   #3
Membre émérite
 
Avatar de viviboss
 
Inscription : août 2006
Messages : 943
Détails du profil
Informations personnelles :
Âge : 30
Localisation : France, Gard (Languedoc Roussillon)

Informations forums :
Inscription : août 2006
Messages : 943
Points : 941
Points : 941
Code :
1
2
3
4
5
6
7
8
9
10
 
$$COMMANDE='';
$$LIVRAISON_SERPIE='';
while($row=mysql_fetch_array($requete)){
$$COMMANDE.=$row['variable'];
$$LIVRAISON_SERPIE.=$row['variable2'];
}
echo $$COMMANDE;
echo $$LIVRAISON_SERPIE;
//te ressort toute les occurences concaténés
Pour concaténer tranquile, tu initialise tes 2 variables de départ à "vide", puis tu utilise le ".=" pour concaténer dans ta variable....

N'oublie pas les espaces !!!
__________________
Veni Vidi Vici
-------------------------
Mes articles : developpez.com ou bien vbview.net
-------------------------
Et SURTOUT ne pas oublier la bible PHP : --> php_manual_fr.chm!!!
Et aussi : --> pear_manual_fr.chm!!!

Ou encore : --> Les tutoriaux & cours PHP de Développez.com
-------------------------
viviboss est déconnecté   Envoyer un message privé Réponse avec citation 00
Vieux 08/12/2006, 10h28   #4
Nouveau Membre du Club
 
Inscription : novembre 2005
Messages : 182
Détails du profil
Informations forums :
Inscription : novembre 2005
Messages : 182
Points : 31
Points : 31
je vais essayer et je te tiens au courant
dafalri est déconnecté   Envoyer un message privé Réponse avec citation 00
Vieux 08/12/2006, 14h28   #5
Nouveau Membre du Club
 
Inscription : novembre 2005
Messages : 182
Détails du profil
Informations forums :
Inscription : novembre 2005
Messages : 182
Points : 31
Points : 31
bon finalement jai tourne les choses autrement en creant carrement une table a part. Donc pas besoin de concatenation.
Mais je garde la reponse bien au chaud !
dafalri 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 13h58.


 
 
 
 
Partenaires

Hébergement Web