Cherche de l'aide pour faire un tableau qui affiche requette sql
Fermé
Mamyroulette
Messages postés
1
Date d'inscription
lundi 3 juin 2013
Statut
Membre
Dernière intervention
3 juin 2013
-
3 juin 2013 à 09:05
hogz - 3 juin 2013 à 09:36
hogz - 3 juin 2013 à 09:36
A voir également:
- Cherche de l'aide pour faire un tableau qui affiche requette sql
- Tableau croisé dynamique - Guide
- Comment faire un tableau - Guide
- Tableau ascii - Guide
- Tableau de combinaison loto 5/90 - Forum Excel
1 réponse
Voici une petite idée.....
La connexion se fait sous forme PDO, naturellement tu peut changer et le mettre en include.
Il y a des champs au format texte et des champs au format date.
ça tu le modifie, ainsi que les couleurs et font.
Maintenant il faut travailler de ton côté....
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Document sans nom</title>
<style type="text/css">
<!--
.Style300 {font-size: 14px;color:#999999;text-align:center;}
.Style400 {font-size: 10px;color:#999999;text-align:center;}
.Style500 {font-size: 14px;color:black;text-align:left;}
-->
</style>
</head>
//Haut du tableau afin qu'il reste fixe
<table width"580" border="0" bgcolor="#333333">
<theard>
<tr>
<th width="30" scope="col"><span class="Style400">TON CHAMPS 1</span></th>
<th width="80" scope="col"><span class="Style400">TON CHAMPS 2</span></th>
<th width="150" scope="col"><span class="Style400">TON CHAMPS 3</span></th>
<th width="150" scope="col"><span class="Style400">TON CHAMPS 4</span></th>
<th width="90" scope="col"><span class="Style400">TON CHAMPS 5</span></th>
<th width="80" scope="col"><span class="Style400">TON CHAMPS 1</span></th>
</tr>
</teard>
<?php
try
{
// On se connecte à MySQL
$bdd = new PDO ('mysql:host=*********;dbname=******', '*******','*********')
or die(print_r($bdd->errorInfo()));
}
catch(Exception $e)
{
// En cas d'erreur, on affiche un message et on arrête tout
die('Erreur : '.$e->getMessage());
}
// Si tout va bien, on peut continuer
// On récupèrere tout le contenu de la table
$reponse = $bdd->query("SELECT * FROM mabase WHERE ******='******' ORDER BY ******");
// On affiche chaque entréee une à une
while ($donnees = $reponse->fetch())
{
?>
//Tableau
<table width="605" border="0">
//Champ format generaliste
<th scope width="30" class="Style500"><?php echo $donnees['TON CHAMPS 1'];?>">Fiche</a></span></th>
//Champ date
<th scope width="80" class="Style500"><?php echo date ("d/m/Y",strtotime($donnees['TON CHAMPS 2'])); ?></span></th>
//Champ format Texte
<th scope width="150" class="Style500"><?php echo htmlentities ($donnees['TON CHAMPS 3']); ?></span></th>
//Champ format Texte
<th scope width="150" class="Style500"><?php echo htmlentities ($donnees['TON CHAMPS 4']); ?></span></th>
//Champ format Texte
<th scope width="90" class="Style500"><?php echo htmlentities ($donnees['TON CHAMPS 5']); ?></span></th>
//Champ date
<th scope width="80" class="Style500"><?php echo date ("d/m/Y",strtotime($donnees['TON CHAMPS 6'])); ?></span></th>
</tr>
</table>
<?php
}
$reponse->closeCursor(); // Termine le traitement de la requête
?>
</div>
La connexion se fait sous forme PDO, naturellement tu peut changer et le mettre en include.
Il y a des champs au format texte et des champs au format date.
ça tu le modifie, ainsi que les couleurs et font.
Maintenant il faut travailler de ton côté....
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Document sans nom</title>
<style type="text/css">
<!--
.Style300 {font-size: 14px;color:#999999;text-align:center;}
.Style400 {font-size: 10px;color:#999999;text-align:center;}
.Style500 {font-size: 14px;color:black;text-align:left;}
-->
</style>
</head>
//Haut du tableau afin qu'il reste fixe
<table width"580" border="0" bgcolor="#333333">
<theard>
<tr>
<th width="30" scope="col"><span class="Style400">TON CHAMPS 1</span></th>
<th width="80" scope="col"><span class="Style400">TON CHAMPS 2</span></th>
<th width="150" scope="col"><span class="Style400">TON CHAMPS 3</span></th>
<th width="150" scope="col"><span class="Style400">TON CHAMPS 4</span></th>
<th width="90" scope="col"><span class="Style400">TON CHAMPS 5</span></th>
<th width="80" scope="col"><span class="Style400">TON CHAMPS 1</span></th>
</tr>
</teard>
<?php
try
{
// On se connecte à MySQL
$bdd = new PDO ('mysql:host=*********;dbname=******', '*******','*********')
or die(print_r($bdd->errorInfo()));
}
catch(Exception $e)
{
// En cas d'erreur, on affiche un message et on arrête tout
die('Erreur : '.$e->getMessage());
}
// Si tout va bien, on peut continuer
// On récupèrere tout le contenu de la table
$reponse = $bdd->query("SELECT * FROM mabase WHERE ******='******' ORDER BY ******");
// On affiche chaque entréee une à une
while ($donnees = $reponse->fetch())
{
?>
//Tableau
<table width="605" border="0">
//Champ format generaliste
<th scope width="30" class="Style500"><?php echo $donnees['TON CHAMPS 1'];?>">Fiche</a></span></th>
//Champ date
<th scope width="80" class="Style500"><?php echo date ("d/m/Y",strtotime($donnees['TON CHAMPS 2'])); ?></span></th>
//Champ format Texte
<th scope width="150" class="Style500"><?php echo htmlentities ($donnees['TON CHAMPS 3']); ?></span></th>
//Champ format Texte
<th scope width="150" class="Style500"><?php echo htmlentities ($donnees['TON CHAMPS 4']); ?></span></th>
//Champ format Texte
<th scope width="90" class="Style500"><?php echo htmlentities ($donnees['TON CHAMPS 5']); ?></span></th>
//Champ date
<th scope width="80" class="Style500"><?php echo date ("d/m/Y",strtotime($donnees['TON CHAMPS 6'])); ?></span></th>
</tr>
</table>
<?php
}
$reponse->closeCursor(); // Termine le traitement de la requête
?>
</div>