Tableau MySQL > PDO
Résolu
Sinistrus
Messages postés
1010
Date d'inscription
Statut
Membre
Dernière intervention
-
Sinistrus Messages postés 1010 Date d'inscription Statut Membre Dernière intervention -
Sinistrus Messages postés 1010 Date d'inscription Statut Membre Dernière intervention -
Bonjour à tous !
Je suis en train de convertir mes pages en PDO et je sollicite votre aide.
Voici le code en MySQL
J'ai essayé ceci mais il ne fonctionne pas...
Pouvez-vous me filer un coup de main svp ?
Je suis en train de convertir mes pages en PDO et je sollicite votre aide.
Voici le code en MySQL
<?php
$NbrCol = 6;
$query = "SELECT * FROM ".$TB_MARQUES." WHERE ".$PAYS."='1' AND Menu='1' ORDER BY Marque ASC;";
$result = mysql_query($query);
$NbreData = mysql_num_rows($result);
$NbrLigne = 0;
if ($NbreData != 0) {
$j = 1;
?>
<table width="100%" border="0" cellspacing="10" cellpadding="0">
<tbody>
<?php while($data = mysql_fetch_array($result)) {if ($j%$NbrCol == 1) {$NbrLigne++;$fintr = 0; ?>
<tr>
<?php } ?>
<td align="center" valign="middle">
<a href="<?php echo URL_RACINE; ?>/categories/<?php echo $data['Lien']; ?>">
<img src="<?php echo URL_IMAGES; ?>/logos/<?php echo $data['Image']; ?>" width="159" height="80" title="<?php echo $data['Descriptions']; ?>" alt="<?php echo $data['Marque']; ?>" />
</a>
</td>
<?php if ($j%$NbrCol == 0) {$fintr = 1; ?>
</tr>
<?php }$j++;} if ($fintr!=1) { ?>
</tr>
<?php } ?>
</tbody>
</table>
<?php } ?>
J'ai essayé ceci mais il ne fonctionne pas...
<?php
$NbrCol = 6;
$statement = $pdo->query("SELECT * FROM ".$TB_MARQUES." WHERE ".$PAYS."='1' AND Menu='1' ORDER BY Marque ASC");
$data = $statement->fetch(PDO::FETCH_ASSOC);
//$result = $statement;
$NbreData = $statement;
$NbrLigne = 0;
if ($NbreData != 0){
$j = 1;
?>
<table width="100%" border="0" cellspacing="10" cellpadding="0">
<tbody>
<?php while($data){if ($j%$NbrCol == 1) {$NbrLigne++;$fintr = 0; ?>
<tr>
<?php } ?>
<td align="center" valign="middle">
<a href="<?php echo URL_RACINE; ?>/categories/<?php echo $data['Lien']; ?>">
<img src="<?php echo URL_IMAGES; ?>/logos/<?php echo $data['Image']; ?>" width="159" height="80" title="<?php echo $data['Descriptions']; ?>" alt="<?php echo $data['Marque']; ?>" />
</a>
</td>
<?php if ($j%$NbrCol == 0) {$fintr = 1; ?>
</tr>
<?php }$j++;} if ($fintr!=1) { ?>
</tr>
<?php } ?>
</tbody>
</table>
<?php } ?>
Pouvez-vous me filer un coup de main svp ?
A voir également:
- Tableau MySQL > PDO
- Tableau word - Guide
- Tableau ascii - Guide
- Trier un tableau excel - Guide
- Tableau croisé dynamique - Guide
- Imprimer tableau excel sur une page - Guide
3 réponses
Bonjour,
Là comme ça.. je dirais :
Cordialement,
Jordane
Là comme ça.. je dirais :
$NbrCol = 6;
$statement = $pdo->query("SELECT * FROM ".$TB_MARQUES." WHERE ".$PAYS."='1' AND Menu='1' ORDER BY Marque ASC");
$data = $statement->fetchAll();
$NbreData = count($data);
$NbrLigne = 0;
if ($NbreData >0){
$j = 1;
?>
<table width="100%" border="0" cellspacing="10" cellpadding="0">
<tbody>
<?php
foreach($data as $D){
if ($j%$NbrCol == 1) {
$NbrLigne++;$fintr = 0;
echo "<tr>";
}
?>
Cordialement,
Jordane
Merci pour ton aide jordane45... mais je n'ai rien qui s'affiche :
J'ai essayé avec
<?php
$NbrCol = 6;
$statement = $pdo->query("SELECT * FROM ".$TB_MARQUES." WHERE ".$PAYS."='1' AND Menu='1' ORDER BY Marque ASC");
$data = $statement->fetchAll();
$NbreData = count($data);
$NbrLigne = 0;
if ($NbreData >0){
$j = 1;
?>
<table width="100%" border="0" cellspacing="10" cellpadding="0">
<tbody>
<?php
foreach($data as $D){
if ($j%$NbrCol == 1) {
$NbrLigne++;$fintr = 0;
?>
<tr>
<?php } ?>
<td align="center" valign="middle">
<a href="<?php echo URL_RACINE; ?>/categories/<?php echo $data['Lien']; ?>">
<img src="<?php echo URL_IMAGES; ?>/logos/<?php echo $data['Image']; ?>" width="159" height="80" title="<?php echo $data['Descriptions']; ?>" alt="<?php echo $data['Marque']; ?>" />
</a>
</td>
<?php if ($j%$NbrCol == 0) {$fintr = 1; ?>
</tr>
<?php }$j++;} if ($fintr!=1) { ?>
</tr>
<?php } ?>
</tbody>
</table>
<?php } ?>
J'ai essayé avec
$data->Imagemais là aussi ça ne fonctionne pas !