bonjour,
j'ai modifié dernièrement un tableau associatif pour un tableau numerique qui provient d'un SELECT mysql.
bon, je me rends compte qque c,est un peu différent.
le probleme, c'est que quand je veux l,afficher dynamiquement avec des echos
il Ya qu'un seul enregistrement qui s'affiche mais plusieurs fois.
je n'avais pas ce probleme avec un tableau associatif
voici comment j'ai structurer mon tableau
et voici quand j'affiche le tableau
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 <?php while($info = mysql_fetch_array($data, MYSQL_NUM)) { $tableau_res = array("id", "time_depart", "date_fr", "voiturier_id","voiture_id", "places_disponibles", "province_depart", "ville_depart", "point_depart", "province_destination", "ville_destination", "point_destination", "prix"); //echo $info[6]; $idTrajet= $info[0], $time_depart = $info[1], $date_fr = $info[2], $voiturierID= $info[3], $voitureID = $info[4], $places_dispo = $info[5], $province_depart= $info[6], $ville_depart= $info[7], $point_depart = $info[8], $province_destination = $info[9], $ville_destination = $info[10], $point_destination = $info[11], $prix = $info[12]; } } ?>
j'ai du déclarer des variables pour chacun des $infos numerotes car il ne voulaient pas s'afficher dans la table et du meme coup, ca a changé la variable $info dans le foreach mais je n'ai aucune idée comment restructurer le foreach
auriez-vous une meilleure idee?
merci a l'avance
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 <?php if (!empty($tableau_res)) { foreach($tableau_res as $info){ //while($info = mysql_fetch_array($data, MYSQL_NUM)) { echo"<tr class='tr'><td align='center'> <a href='../transactions/Transaction_Depart.php?idTrajet=".$idTrajet."'>Choisir</a> </td>"; echo'<td><strong>'.$date_fr.'</strong><br />'.$time_depart.'</td>'; echo'<td><strong>'.$ville_depart.'</strong> ('.$province_depart.')<br />'.$point_depart.'</td>'; echo'<td><strong>'.$ville_destination.'</strong> ('.$province_destination.')<br />'.$point_destination.'</td>'; echo'<td><strong>'.$places_dispo.'</strong></td>'; echo'<td>'.$prix.'</strong>$cad</td>'; '<td> </td>'; '</tr>'; } } ?>
Partager