Boucle sur ID - PHP

Fermé
Webster95 Messages postés 553 Date d'inscription lundi 5 novembre 2007 Statut Membre Dernière intervention 9 juillet 2013 - 7 mai 2012 à 14:55
hervé56 Messages postés 269 Date d'inscription lundi 15 novembre 2010 Statut Membre Dernière intervention 25 mars 2017 - 7 mai 2012 à 16:42
Bonjour,

Dans le cadre d'un projet, je dois afficher les commandes passés sur un site.
J'ai alors le numéro de commande, l'article...

Je fait un boucle pour récupérer les résultats. Jusqu'à la, tout va bien.
Dans ma boucle while, j'affiche 1 ligne avec l'id et l'article en question.

J'aimerais que, quand l'ID revient 2 fois de suite, les 2 articles soient dans la meme ligne.

Autrement dit, tant que l'ID = l'ID précédent, j'ajoute l'article à la ligne.

Précision: Je suis en mysql_fetch_object.


Merci !


4 réponses

hervé56 Messages postés 269 Date d'inscription lundi 15 novembre 2010 Statut Membre Dernière intervention 25 mars 2017 10
7 mai 2012 à 15:05
(montre du code stp)
0
Webster95 Messages postés 553 Date d'inscription lundi 5 novembre 2007 Statut Membre Dernière intervention 9 juillet 2013 142
7 mai 2012 à 15:06
  while ($order = db_fetch_object($result)) {
$row = array(
		  'data' => array(
			array('data' => '<input type=checkbox id="check-'.$order->order_product_id.'"/>'),
			array('data' => $order->order_id),
			array('data' => $date_formate),
			array('data' => $order->title),
			array('data' => $order_name_nom),
                        array('data' => $order_name_adresse1),
                        array('data' => $order_name_adresse2),
                        array('data' => $order_name_cp),
                        array('data' => $order_name_ville),
                        array('data' => $order_name_pays),
			$actions_status,
			array('data' => $export_csv, 'class' => 'hidden'),
		  ),
		  'id' => 'order-product-'. $order->order_product_id,
		);

}



C'est du Drupal.


0
hervé56 Messages postés 269 Date d'inscription lundi 15 novembre 2010 Statut Membre Dernière intervention 25 mars 2017 10
7 mai 2012 à 15:08
(==> non c'est du php)
0
Webster95 Messages postés 553 Date d'inscription lundi 5 novembre 2007 Statut Membre Dernière intervention 9 juillet 2013 142
Modifié par Webster95 le 7/05/2012 à 15:10
Oui je sais bien
Mais dans une Node Drupal
0
hervé56 Messages postés 269 Date d'inscription lundi 15 novembre 2010 Statut Membre Dernière intervention 25 mars 2017 10
7 mai 2012 à 15:29
tu insères une variable a la fin de ton while qui prend l'id a checker
tu fais le check au debut du while et c'est bon :)
0
Webster95 Messages postés 553 Date d'inscription lundi 5 novembre 2007 Statut Membre Dernière intervention 9 juillet 2013 142
7 mai 2012 à 15:33
En fait, j'ai fait ça, mais je ne sais pas comment regrouper les articles. Autrement dit, comment retrouver l'article précdent.

0
Webster95 Messages postés 553 Date d'inscription lundi 5 novembre 2007 Statut Membre Dernière intervention 9 juillet 2013 142
7 mai 2012 à 15:40
à noter que, si j'ai plusieurs produit dans un meme commande, il faut meme les produit sur une ligne, et ne plus afficher la premiere
0
hervé56 Messages postés 269 Date d'inscription lundi 15 novembre 2010 Statut Membre Dernière intervention 25 mars 2017 10
7 mai 2012 à 16:42
bé ca tu le gere dans ta boucle, apres avoir checké l'id avec l'id precedente...
0