Remplir un tableau horizontalement

roro - Modifié par @karamel le 9/12/2016 à 10:28
 roro - 22 déc. 2016 à 10:54
Bonjour,
je viens encore a vous parce que j'ai essayé de faire mais je n'y suis pas arrivée ,mon probleme se situe au niveau du remplissage de mon tableau jai reussit selon moi a l'afficher mais je ne narriver a le remplir horizontalement voici le resultat que jai avec le code
SOCIETE A SOCIETEB
nombre 1
montant 200000
nombre 2
mais je veux que mon tableau se remplisse comme ceci
SOCIETE A SOCIETEB
nombre 1 5
montant 200000 500000
nombre
aidez moi svp
voici mon code
<?php
$etat=mysql_query("SELECT DISTINCT(libelle1),libelle2,libelle3 FROM  categorie WHERE autres=1 ORDER BY ordre");
   while($trim=mysql_fetch_array($etat)){
$champs1=$trim[0];
$champs2=$trim[1];
$champs3=$trim[2];

$trimestre=mysql_query("SELECT count(*)AS numero,sum( montant_encaisse)as montant
FROM recours_encaisse,compagnies
WHERE nom_compagnie_adv=nom_compagnie
GROUP BY nom_compagnie_adv");
$i=0;

$a=mysql_fetch_array($trimestre);
$ch1=$a[0];
$ch2=$a[1];
?> 
<tr>
<th scope="col"><?php echo $champs1?></th>
<th scope="col"><?php echo $champs2?></th>
<td scope="col"><?php ?></td>
<td scope="col"><?php ?></td>
<td scope="col"></td>
<td scope="col"></td>
<td scope="col"></td>
<td scope="col"></td>
</tr>

<tr>
<td scope="col"><?php ?></td>
<th scope="col"><?php echo $champs3 ?></th>
<td scope="col"><?php ?></td>
<td scope="col"></td>
<td scope="col"></td>
<td scope="col"><?php ?></td>
<td scope="col"><?php  ?></th>
<td scope="col"></td>

</tr>


<?php
}
mysql_free_result($trimestre);
}

?>
</table>

4 réponses

serge285 Messages postés 6 Date d'inscription lundi 28 novembre 2016 Statut Membre Dernière intervention 20 décembre 2016
19 déc. 2016 à 20:18
Salut,
si cela ne te dérange pas alors j'aimerais bien avoir ta base de données afin d'y voir plus claire mais tu as pas mal d'erreur de syntaxe.
0
voici la structure de ma BDD

Categorie (id_categorie,libelle1, libelle2,libelle3, autres, société ,ordre)

Compagnies (id_compagnies, nom_compagnie )

recours_encaisse(id_recours_encaisse,anne_enregistre,num-trimestre,date_misecause_recour_encaisse,num_sun_recours_encaisse,assure_recour_encaisse,#nom_compagnie_adv,num_sinsitre_advers_recour_encaisse,nom_assure_advers_recours_encaisse,montant_encaisse,observation_recours_encaisse,#id_categorie)

recours_a_encaisse(id_recours_a_encaisse,annee,num-trim,date_mise_cause,num_sinistre,nom_assure,#compagnie_adverse,num_sinsitre_adverse,nom_assure_adverse,montant_a_encaisse,observation_recours_a_encaisse,#id_categorie)

login(id,pseudo,pass,type)

paiement(id_paiment,date_paiement,paiement_compagnie,num_sinistre_paiement,montant_paiement,#id_recours_encaisse,#id_recours_a_encaisse)

paiement_regle(id_paiment_regler,date_paiement_regler,paiement_compagnie_regler,num_sinistre_paiement_regler,montant_paiement_regler,#id_recours_encaisse,#id_recours_a_encaisse)
0
j'ai recu a trouver un myen de remplir mon tableau horizontalement avec les attributs comme id et headers mais mon soucis actuellement c'est que toutes les donnees ne s'affiches pas dans le tableau c'est seulment le premier enregistrement qui s'affiche
0
voici mon nouveau code

<tr class="style3">
<th width="93" colspan="2" align="center" scope="colgroup" id="libelle" >LIBELLE</th>
<th width="93" colspan="4" align="center" scope="colgroup"id="marche" >MARCHE NATIONNALE </th>
<th width="93" align="center" rowspan="2" id="pays">PAYS ETRANGERS</th>
<th width="93" align="center" rowspan="2" id="total">TOTAL</th>
</tr>
<tr>
<th scope="col" ></th>
<th scope="col"></th>
<th class="center" id=marche>SOCIETE A</th>
<th scope="col" id=marche>SOCIETE B</th>
<th scope="col"id=marche>SOCIETE C</th>
<th scope="col" id=marche>SOCIETE D</th>
</tr>
</thead>
</div>
<tbody>



<?php

$trimestre=mysql_query("SELECT count(*)AS numero,sum( montant_encaisse)as montant
FROM recours_encaisse,compagnies
WHERE nom_compagnie_adv=nom_compagnie
GROUP BY nom_compagnie_adv") or die(mysql_error());;
$i=0;
while($a=mysql_fetch_array($trimestre))
{

$ch1=$a[0];
$ch2=$a[1];
$i++;
?>


<tr>
<th headers="libelle" id="stock">Stock a l ouverture</th>
<th headers="libelle" id="nombre">nombre de sinistre</th>
<td headers="stock marche "><?php echo $ch1?></td>
<td headers="stock marche"><?php echo $ch1?></td>
<td headers="stock marche"><?php echo $ch1?></td>
<td ><?php ?></td>
<td><?php ?></td>
<td headers=" libelle marche" ><?php echo $ch1?></td>
</tr>

<tr>
<td ></td>
<td >Montant</td>
<td ><?php echo $ch2?></td>
<td ></td>
<td ></td>
<td ><?php ?></td>
<td ><?php echo $ch2?></td>
<td ></td>
</tr>

<tr>
<th headers="marche" id="socie" >Réclamations de la periode</th>
<th headers="marche" id="nom">nombre de sinistre</th>
<td headers="libelle marche " ><?php echo $ch1?></td>
<td headers="libelle marche" ><?php echo $ch1?></td>
<td headers="libelle marche" ><?php echo $ch1?></td>
<td headers="libelle marche" ><?php echo $ch1?></td>
<td headers="libelle marche" ><?php echo $ch1?></td>
<td headers="libelle marche" ><?php echo $ch1?></td>
</tr>
<tr>
<td ></td>
<td >Montant</td>
<td ><?php echo $ch2?></td>
<td ></td>
<td ></td>
<td ><?php ?></td>
<td ><?php echo $ch2?></td>
<td ></td>
</tr>
<tr>
<th headers="marche" id="paiement" >Paiement de la periode</th>
<th headers="marche" id="nombr">nombre de sinistre</th>
<td headers="libelle marche " ><?php echo $ch1?></td>
<td headers="libelle marche" ><?php echo $ch1?></td>
<td headers="libelle marche" ><?php echo $ch1?></td>
<td headers="libelle marche" ><?php ?></td>
<td headers="libelle marche" ><?php echo $ch1?></td>
<td headers="libelle marche" ><?php echo $ch1?></td>
</tr>
<tr>
<td ></td>
<td >Montant</td>
<td ><?php echo $ch2?></td>
<td ></td>
<td ></td>
<td ><?php ?></td>
<td ><?php echo $ch2?></td>
<td ></td>
</tr>
<tr>
<th headers="marche" id="clos" >Stock a la cloture</th>
<th headers="marche" id="nombr">nombre de sinistre</th>
<td headers="libelle marche " ><?php echo $ch1?></td>
<td headers="libelle marche" ><?php echo $ch1?></td>
<td headers="libelle marche" ><?php echo $ch1?></td>
<td headers="libelle marche" ><?php echo $ch1?></td>
<td headers="libelle marche" ><?php echo $ch1?></td>
<td headers="libelle marche" ><?php echo $ch1?></td>
</tr>
<tr>
<td ></td>
<td >Montant</td>
<td ><?php echo $ch2?></td>
<td ></td>
<td ></td>
<td ><?php ?></td>
<td ><?php echo $ch2?></td>
<td ></td>
</tr>
</tbody>
</table>


<?php

}
}
?>
</form>

</div>
</div>
</body>

</html>

merci pour votre aide
0
Rejoignez-nous