Bonjour
J'aimerais vous soumettre un script php qui me permet de
faire la comparaison des caractéristiques de 2 ou 3 produits selon l'ID
choisi.
Je vous donne un exemple de la requete:
SELECT * FROM table WHERE id IN ('1','5','10')
Pour que les resultats obtenus s'affiche comme ceci :
resultat1 resultat2 resultat3
capacité 10 Go 5 Go 7 Go
poids 5kg 7kg 8kg
vitesse 4000Tpm 3000tpm 2000tpm
J'utilise ce script :
<table border="0">
<tr>
<?php
$img_endRow = 0;
$img_columns = 3; // number of columns
$img_hloopRow1 = 0; // first row flag
do{if($img_endRow == 0 && $img_hloopRow1++ != 0) echo "<tr>";
?>
<td><table border="0">
<tr>
<td><?php echo $row_detail['capacite']; ?></td>
</tr>
<tr>
<td><?php echo $row_detail['poids']; ?></td>
</tr>
<tr>
<td><?php echo $row_detail['vitesse']; ?></td>
</tr>
</table></td>
<?php$img_endRow++;
if($img_endRow >= $img_columns){
?>
</tr>
<?php
$img_endRow = 0;
}
}while($row_detail = mysql_fetch_assoc($detail));
if($img_endRow != 0){
while($img_endRow < $img_columns){
echo("<td> </td>");
$img_endRow++;
}
echo("</tr>");
}?>
</table>
POur ce premier cas de figure les resultats s'affiche correctement
Pour mon 2ème cas de figure selon ma base de donnée
idproduit designation valeur
1 capacité 20Go
1 poids 3kg
1 vitesse 5000tpm
4 capacité 10go
4 poids 4kg
4 vitesse 4000tpm
les résultat se mélange c'est à dire que pour un type de produit la
base de donnée renvoi plusieurs valeur donc l'affiche n'est pas
correctement en colonne et les données sont donc mélangées
<table border="0">
<tr>
<?php
$img_endRow = 0;
$img_columns = 3; // number of columns
$img_hloopRow1 = 0; // first row flag
do{if($img_endRow == 0 && $img_hloopRow1++ != 0) echo "<tr>";
?>
<td><table border="0">
<tr>
<td><?php echo $row_detail['valeurs']; ?></td>
</tr>
</table></td>
<?php$img_endRow++;
if($img_endRow >= $img_columns){
?>
</tr>
<?php
$img_endRow = 0;
}
}while($row_detail = mysql_fetch_assoc($detail));
if($img_endRow != 0){
while($img_endRow < $img_columns){
echo("<td> </td>");
$img_endRow++;
}
echo("</tr>");
}?>
</table>
Alors si quelqu'un peux m'aider
