par
barakobama95 » 11 nov. 2013, 17:34
Voila mon code :
<?php
// Ce script doit contenir tout ce qui est en dessus du <doctype...
// SANS NI session_start(); NI error_reporting(E_ALL); NI setlocale(LC_TIME, "fr_FR.utf8","fra");
// (ils sont déjà dans le template)
mysql_connect('127.0.0.1', 'root', '');
mysql_select_db('2013-alcool');
if(!isset($_GET['tri']))$_GET['tri']='NomTypeProduit';
$sql = "SELECT `moser-typeproduit`.`NomTypeProduit`,`moser-marque`.`NomMarque`,`moser-produit`.`NomProduit`,`moser-produit`.`PourcentAlcool`,
`moser-marque`.`LogoMarque`,`moser-produit`.`CouleurRouge`,`moser-produit`.`CouleurVert`,`moser-produit`.`CouleurBleu`,
`moser-produit`.`QuantVente`,`moser-produit`.`EstEffervescent` FROM `moser-typeproduit`
LEFT JOIN `moser-produit` ON `moser-typeproduit`.`idTypeProduit` = `moser-produit`.`TypeProduitId`
LEFT JOIN `moser-marque` ON `moser-produit`.`MarqueId` = `moser-marque`.`idMarque` ORDER BY `".$_GET['tri']."` ASC";
$result = mysql_query($sql) or die (mysql_error()." dans $sql");
$nb_enreg=mysql_num_rows($result);
for ($i=0; $i<$nb_enreg; $i++)
{
$row = mysql_fetch_assoc($result);
$rows[]=$row;
$fusion[$row['NomTypeProduit']]=@$fusion[$row['NomTypeProduit']]+1;
}
?>
<?php
// Ce script doit contenir tout ce qui est à afficher dans le body
echo '<table border=1 width=100% >';
?>
<TH > Produit </TH>
<TH > Producteur/Marque </TH>
<TH> Nom du produit </TH>
<TH> % alcool </TH>
<TH> Logo </TH>
<TH> R</TH>
<TH> V</TH>
<TH> B </TH>
<TH> Quantité de vente </TH>
<TH> Effervescent </TH>
<th> Couleur hexa </th>
<?php
$precedent="";
for ($i=0; $i<count($rows); $i++)
{
echo '<tr>';
foreach ($row as $key=>$field)
{
if ($key=="NomTypeProduit")
{
if ($field!=$precedent) echo '<td ALIGN=CENTER >' . $field . '</td>';
else echo "<tr><td rowspan ></td></tr>"; // Si identique, enlever ce TD quand il y aura les fusions
$precedent=$field;
}
else echo '<td ALIGN=CENTER >' . $field . '</td>';
}
if ($key=="CouleurRouge" || $key=="CouleurVert" || $key=="CouleurBleu");
//echo "string dechex (int $)" ;
echo "<td>".$row['CouleurRouge'].$row['CouleurVert'].$row['CouleurBleu']."</td>";
echo '</tr>';
}
echo '</table>';
?>
Voila mon code :
<?php
// Ce script doit contenir tout ce qui est en dessus du <doctype...
// SANS NI session_start(); NI error_reporting(E_ALL); NI setlocale(LC_TIME, "fr_FR.utf8","fra");
// (ils sont déjà dans le template)
mysql_connect('127.0.0.1', 'root', '');
mysql_select_db('2013-alcool');
if(!isset($_GET['tri']))$_GET['tri']='NomTypeProduit';
$sql = "SELECT `moser-typeproduit`.`NomTypeProduit`,`moser-marque`.`NomMarque`,`moser-produit`.`NomProduit`,`moser-produit`.`PourcentAlcool`,
`moser-marque`.`LogoMarque`,`moser-produit`.`CouleurRouge`,`moser-produit`.`CouleurVert`,`moser-produit`.`CouleurBleu`,
`moser-produit`.`QuantVente`,`moser-produit`.`EstEffervescent` FROM `moser-typeproduit`
LEFT JOIN `moser-produit` ON `moser-typeproduit`.`idTypeProduit` = `moser-produit`.`TypeProduitId`
LEFT JOIN `moser-marque` ON `moser-produit`.`MarqueId` = `moser-marque`.`idMarque` ORDER BY `".$_GET['tri']."` ASC";
$result = mysql_query($sql) or die (mysql_error()." dans $sql");
$nb_enreg=mysql_num_rows($result);
for ($i=0; $i<$nb_enreg; $i++)
{
$row = mysql_fetch_assoc($result);
$rows[]=$row;
$fusion[$row['NomTypeProduit']]=@$fusion[$row['NomTypeProduit']]+1;
}
?>
<?php
// Ce script doit contenir tout ce qui est à afficher dans le body
echo '<table border=1 width=100% >';
?>
<TH > Produit </TH>
<TH > Producteur/Marque </TH>
<TH> Nom du produit </TH>
<TH> % alcool </TH>
<TH> Logo </TH>
<TH> R</TH>
<TH> V</TH>
<TH> B </TH>
<TH> Quantité de vente </TH>
<TH> Effervescent </TH>
<th> Couleur hexa </th>
<?php
$precedent="";
for ($i=0; $i<count($rows); $i++)
{
echo '<tr>';
foreach ($row as $key=>$field)
{
if ($key=="NomTypeProduit")
{
if ($field!=$precedent) echo '<td ALIGN=CENTER >' . $field . '</td>';
else echo "<tr><td rowspan ></td></tr>"; // Si identique, enlever ce TD quand il y aura les fusions
$precedent=$field;
}
else echo '<td ALIGN=CENTER >' . $field . '</td>';
}
if ($key=="CouleurRouge" || $key=="CouleurVert" || $key=="CouleurBleu");
//echo "string dechex (int $)" ;
echo "<td>".$row['CouleurRouge'].$row['CouleurVert'].$row['CouleurBleu']."</td>";
echo '</tr>';
}
echo '</table>';
?>