Afficher tous mes enregistrement dans un seul tabl
Résolu
baabs12
Messages postés
12
Date d'inscription
Statut
Membre
Dernière intervention
-
baabs12 -
baabs12 -
Bonjour,
j'ai écrit un script qui m'affiche le contenu d'une table dans sql server, seulement au lieu que j'ai un seul tableau, j'ai pour chaque ligne un tableau. J'aimerai savoir comment faire pour pour tout avoir sur un seul et unique tableau.
Le script est le suivant:
j'ai écrit un script qui m'affiche le contenu d'une table dans sql server, seulement au lieu que j'ai un seul tableau, j'ai pour chaque ligne un tableau. J'aimerai savoir comment faire pour pour tout avoir sur un seul et unique tableau.
Le script est le suivant:
<?php if (isset($_POST['pseudo'])) // Si la variable existe { if (isset($_POST['pwd'])) { $myServer = "serveur"; $myUser = "sa"; $myPass = "123"; $myDB = "restaurant"; // connection to the database $dbhandle = mssql_connect($myServer, $myUser, $myPass) or die("Impossible de se connecter sur le serveur $myServer"); // select a database to work with $selected = mssql_select_db($myDB, $dbhandle) or die("Impossible d'ouvrir la base $myDB"); echo "Vous êtes bien connectés sur la base " . $myDB . " du serveur " . $myServer . "."; $reponse = mssql_query("SELECT code_client,carte,montant,produit,entreprise,Date1 FROM TRANSACTIONS, DETAIL_CLIENT WHERE DETAIL_CLIENT.NUMERO = TRANSACTIONS.CARTE"); echo $reponse; $test = $_POST['commission']; echo $_POST['commission']; if ($test = true) { while ($donnees = mssql_fetch_array($reponse)) { $val = $donnees['montant']; $commission6 = 0.06 * $val; $commission40 = 250 ; ?> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="fr" > <head> <title>Recouvrement</title> <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" /> <link rel="stylesheet" media="screen" type="text/css" title="Design" href="design.css" /> </head> <body> <p> <table> <caption>RECOUVREMENT</caption> <thead> <!-- En-tête du tableau --> <tr> <th>Code Client</th> <th>Numero Carte</th> <th>Montant</th> <th>Produit</th> <th>Entreprise</th> <th>Date</th> <th>Commission 6%</th> </tr> </thead> <tfoot> <!-- Pied de tableau --> <tr> <th>Code Client</th> <th>Numero Carte</th> <th>Montant</th> <th>Produit</th> <th>Entreprise</th> <th>Date</th> <th>Commission 6%</th> </tr> </tfoot> <tbody> <!-- Corps du tableau --> <tr> <td><?php echo $donnees['code_client']; ?></td> <td><?php echo $donnees['carte']; ?></td> <td><?php echo $donnees['montant']; ?></td> <td><?php echo $donnees['produit']; ?></td> <td><?php echo $donnees['entreprise']; ?></td> <td><?php echo $donnees['Date1']; ?></td> <td><?php echo $commission6; ?></td> </tr> </tbody> </table> </P> </body> </html> <?php } } } } //deconnection of the database mssql_close(); ?>
A voir également:
- Afficher tous mes enregistrement dans un seul tabl
- Comment enregistrer un mail dans mes documents - Guide
- Enregistrement mp3 gratuit - Télécharger - Streaming audio
- Comment couper un enregistrement audio - Guide
- Afficher le 0 devant un nombre dans excel - Guide
- Double affichage sur un seul écran - Guide
1 réponse
Bonjour,
c'est sur que si tu mets tout dans la boucle while tu vas avoir autant de tableaux que de pasages de la boucle
essayes comme ça:
c'est sur que si tu mets tout dans la boucle while tu vas avoir autant de tableaux que de pasages de la boucle
essayes comme ça:
<?php if (isset($_POST['pseudo'])) // Si la variable existe { if (isset($_POST['pwd'])) { $myServer = "serveur"; $myUser = "sa"; $myPass = "123"; $myDB = "restaurant"; // connection to the database $dbhandle = mssql_connect($myServer, $myUser, $myPass) or die("Impossible de se connecter sur le serveur $myServer"); // select a database to work with $selected = mssql_select_db($myDB, $dbhandle) or die("Impossible d'ouvrir la base $myDB"); echo "Vous êtes bien connectés sur la base " . $myDB . " du serveur " . $myServer . "."; $reponse = mssql_query("SELECT code_client,carte,montant,produit,entreprise,Date1 FROM TRANSACTIONS, DETAIL_CLIENT WHERE DETAIL_CLIENT.NUMERO = TRANSACTIONS.CARTE"); echo $reponse; $test = $_POST['commission']; echo $_POST['commission']; if ($test = true) { ?> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="fr" > <head> <title>Recouvrement</title> <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" /> <link rel="stylesheet" media="screen" type="text/css" title="Design" href="design.css" /> </head> <body> <p> <table> <tbody> <!-- Corps du tableau --> <caption>RECOUVREMENT</caption> <thead> <!-- En-tête du tableau --> <tr> <th>Code Client</th> <th>Numero Carte</th> <th>Montant</th> <th>Produit</th> <th>Entreprise</th> <th>Date</th> <th>Commission 6%</th> </tr> </thead> <?php while ($donnees = mssql_fetch_array($reponse)) { $val = $donnees['montant']; $commission6 = 0.06 * $val; $commission40 = 250 ; ?> <tr> <td><?php echo $donnees['code_client']; ?></td> <td><?php echo $donnees['carte']; ?></td> <td><?php echo $donnees['montant']; ?></td> <td><?php echo $donnees['produit']; ?></td> <td><?php echo $donnees['entreprise']; ?></td> <td><?php echo $donnees['Date1']; ?></td> <td><?php echo $commission6; ?></td> </tr> <?php } //fin de la boucle while ?> <tfoot> <!-- Pied de tableau --> <tr> <th>Code Client</th> <th>Numero Carte</th> <th>Montant</th> <th>Produit</th> <th>Entreprise</th> <th>Date</th> <th>Commission 6%</th> </tr> </tfoot> </tbody> </table> </P> </body> </html> <?php } } } //deconnection of the database mssql_close(); ?>
merci beaucoup ça marche. Je ne pensais pas que mettre les balises HTML hors de la boucle pouvait me permettre d'afficher les données.
Encore une fois merci