par
jeanmed » 05 déc. 2007, 18:14
Voila c est mieux ???
<?
$tdQt="";
$tdQt2='<tr><td align="center" id="filetTRb"><span id="titre">fdsfsdfsd</span></td><td align="center" id="filetTRb"><span id="titre">fdsfsdfsd</span></td>';
//recuperer le nombre de quantité différent q nq doublons
$requetteQt="SELECT DISTINCT `quantite` FROM `tarif_quantite` WHERE `id_famille` =1";
$req_Qt = mysql_query($requetteQt) or die('Erreur SQL (Ligne Quantite) : <br />'.$requetteQt);
while($BoucQt=mysql_fetch_array($req_Qt))
{
$tabQt[]=array("qt"=>$BoucQt['quantite']);
}
//tabelau trié
sort($tabQt, SORT_DESC);
$nbQt=count($tabQt);
//fabrication du haut du tableau
for($i=0;$i<$nbQt;$i++)
{
$tdQt.='<td align="center" id="filetTRb"><span id="titre">'.$tabQt[$i]['qt'].'</span></td>';
}
//fin tableau
//boucle sur toute les quantié avec comme id famille 1
$leprod="";
$requetteCompQt="SELECT * FROM `tarif_quantite` WHERE `id_famille` =1 ORDER BY `tarif_quantite`.`id_produit` ASC ";
$req_Comp = mysql_query($requetteCompQt) or die('Erreur SQL (Ligne Quantite) : <br />'.$requetteCompQ);
$n=0;
while($BouCo=mysql_fetch_array($req_Comp))
{
//si quantité pas comme dans tableau
if($tabQt[$n]["qt"]==$BouCo['quantite'])
{print("egal : valeur tab -".$tabQt[$n]["qt"]." / valeur quantité -".$BouCo['quantite']."<br>");
$qtTemp='';}
else
{print("pas egal : valeur tab -".$tabQt[$n]["qt"]." / valeur quantité -".$BouCo['quantite']."<br>");
$qtTemp='<td align="center" id="filetTRb"><span id="titre"> - </span></td>'; }
//tentative de faire un teste sur les quantité mais sa merde
$n++;
//tentative de faire une ligne par id_produit sa marche apparement !!!
//print($leprod."<br>");
if($leprod=="")
{
$leprod=$BouCo['id_produit'];
$tdQt2.=$qtTemp.'<td align="center" id="filetTRb"><span id="titre">'.$BouCo['prix_ht'].'</span></td>';<br>
}
elseif($leprod==$BouCo['id_produit'])
{$tdQt2.=$qtTemp.'<td align="center" id="filetTRb"><span id="titre">'.$BouCo['prix_ht'].'</span></td>';
$leprod=$BouCo['id_produit'];}
else
{
$tdQt2.=$qtTemp.'</tr><tr><td align="center" id="filetTRb"><span id="titre">fdsfsdfsd</span></td><td align="center" id="filetTRb">
<span id="titre">fdsfsdfsd</span></td><td align="center" id="filetTRb"><span id="titre">'.$BouCo['prix_ht'].'</span></td>';
$leprod=$BouCo['id_produit'];
}
}
//fabrication du menu du haut
$tdQt2.='</tr>';
//je print le tous pour faire un tableau html
$modTemp=' ';
$modTemp.='<table width="100%" border="0" cellspacing="0" cellpadding="0" id="tableauTarif">
<tr>
<td align="center" id="filetTRb"><span id="titre">Reference</span></td>
<td align="center" id="filetTRb"><span id="titre">Designation</span></td>
'.$tdQt.'
</tr>'.$tdQt2.'';
$modTemp.='</table>';
print($modTemp);
?>
Ma base mysql :
Code : Tout sélectionner
CREATE TABLE IF NOT EXISTS `tarif_quantite` (
`id` int(11) NOT NULL auto_increment,
`id_produit` varchar(255) NOT NULL default '',
`id_famille` int(11) NOT NULL default '0',
`quantite` varchar(255) NOT NULL default '',
`prix_ht` varchar(255) NOT NULL default '',
`poid` varchar(255) NOT NULL default '',
`promo` enum('ok','no') NOT NULL default 'no',
`date_deb` date NOT NULL default '0000-00-00',
`date_fin` date NOT NULL default '0000-00-00',
`remise` decimal(10,0) NOT NULL default '0',
PRIMARY KEY (`id`)
) ENGINE=MyISAM DEFAULT CHARSET=latin1 AUTO_INCREMENT=17 ;
--
-- Contenu de la table `tarif_quantite`
--
INSERT INTO `tarif_quantite` (`id`, `id_produit`, `id_famille`, `quantite`, `prix_ht`, `poid`, `promo`, `date_deb`, `date_fin`, `remise`) VALUES
(1, '1', 1, '100', '13.63', '0.153', 'ok', '0000-00-00', '0000-00-00', 50),
(2, '1', 1, '250', '15.79', '0.359', 'ok', '0000-00-00', '0000-00-00', 0),
(3, '1', 1, '500', '19.93', '0.711', 'no', '0000-00-00', '0000-00-00', 0),
(4, '1', 1, '1000', '25.08', '2.914', 'no', '0000-00-00', '0000-00-00', 0),
(5, '1', 1, '2000', '39.37', '4.291', 'no', '0000-00-00', '0000-00-00', 0),
(6, '1', 1, '3000', '53.66', '2.914', 'no', '0000-00-00', '0000-00-00', 0),
(7, '1', 1, '4000', '67.95', '5.668', 'no', '0000-00-00', '0000-00-00', 0),
(8, '1', 1, '5000', '82.25', '7.045', 'no', '0000-00-00', '0000-00-00', 0),
(9, '1', 1, '7500', '120.53', '10.648', 'no', '0000-00-00', '0000-00-00', 0),
(10, '1', 1, '10000', '156.25', '14.09', 'no', '0000-00-00', '0000-00-00', 0),
(11, '1', 1, '20000', '304.27', '28.18', 'no', '0000-00-00', '0000-00-00', 0),
(12, '2', 1, '300', '40', '', 'no', '0000-00-00', '0000-00-00', 0),
(13, '2', 1, '400', '50', '', 'no', '0000-00-00', '0000-00-00', 0),
(14, '1', 1, '100', '56', '', 'no', '0000-00-00', '0000-00-00', 0),
(15, '3', 1, '500', '56', '', 'no', '0000-00-00', '0000-00-00', 0),
(16, '3', 1, '600', '95', '', 'no', '0000-00-00', '0000-00-00', 0);
Voila c est mieux ???
[php]
<?
$tdQt="";
$tdQt2='<tr><td align="center" id="filetTRb"><span id="titre">fdsfsdfsd</span></td><td align="center" id="filetTRb"><span id="titre">fdsfsdfsd</span></td>';
//recuperer le nombre de quantité différent q nq doublons
$requetteQt="SELECT DISTINCT `quantite` FROM `tarif_quantite` WHERE `id_famille` =1";
$req_Qt = mysql_query($requetteQt) or die('Erreur SQL (Ligne Quantite) : <br />'.$requetteQt);
while($BoucQt=mysql_fetch_array($req_Qt))
{
$tabQt[]=array("qt"=>$BoucQt['quantite']);
}
//tabelau trié
sort($tabQt, SORT_DESC);
$nbQt=count($tabQt);
//fabrication du haut du tableau
for($i=0;$i<$nbQt;$i++)
{
$tdQt.='<td align="center" id="filetTRb"><span id="titre">'.$tabQt[$i]['qt'].'</span></td>';
}
//fin tableau
//boucle sur toute les quantié avec comme id famille 1
$leprod="";
$requetteCompQt="SELECT * FROM `tarif_quantite` WHERE `id_famille` =1 ORDER BY `tarif_quantite`.`id_produit` ASC ";
$req_Comp = mysql_query($requetteCompQt) or die('Erreur SQL (Ligne Quantite) : <br />'.$requetteCompQ);
$n=0;
while($BouCo=mysql_fetch_array($req_Comp))
{
//si quantité pas comme dans tableau
if($tabQt[$n]["qt"]==$BouCo['quantite'])
{print("egal : valeur tab -".$tabQt[$n]["qt"]." / valeur quantité -".$BouCo['quantite']."<br>");
$qtTemp='';}
else
{print("pas egal : valeur tab -".$tabQt[$n]["qt"]." / valeur quantité -".$BouCo['quantite']."<br>");
$qtTemp='<td align="center" id="filetTRb"><span id="titre"> - </span></td>'; }
//tentative de faire un teste sur les quantité mais sa merde
$n++;
//tentative de faire une ligne par id_produit sa marche apparement !!!
//print($leprod."<br>");
if($leprod=="")
{
$leprod=$BouCo['id_produit'];
$tdQt2.=$qtTemp.'<td align="center" id="filetTRb"><span id="titre">'.$BouCo['prix_ht'].'</span></td>';<br>
}
elseif($leprod==$BouCo['id_produit'])
{$tdQt2.=$qtTemp.'<td align="center" id="filetTRb"><span id="titre">'.$BouCo['prix_ht'].'</span></td>';
$leprod=$BouCo['id_produit'];}
else
{
$tdQt2.=$qtTemp.'</tr><tr><td align="center" id="filetTRb"><span id="titre">fdsfsdfsd</span></td><td align="center" id="filetTRb">
<span id="titre">fdsfsdfsd</span></td><td align="center" id="filetTRb"><span id="titre">'.$BouCo['prix_ht'].'</span></td>';
$leprod=$BouCo['id_produit'];
}
}
//fabrication du menu du haut
$tdQt2.='</tr>';
//je print le tous pour faire un tableau html
$modTemp=' ';
$modTemp.='<table width="100%" border="0" cellspacing="0" cellpadding="0" id="tableauTarif">
<tr>
<td align="center" id="filetTRb"><span id="titre">Reference</span></td>
<td align="center" id="filetTRb"><span id="titre">Designation</span></td>
'.$tdQt.'
</tr>'.$tdQt2.'';
$modTemp.='</table>';
print($modTemp);
?>[/php]
Ma base mysql :
[code]
CREATE TABLE IF NOT EXISTS `tarif_quantite` (
`id` int(11) NOT NULL auto_increment,
`id_produit` varchar(255) NOT NULL default '',
`id_famille` int(11) NOT NULL default '0',
`quantite` varchar(255) NOT NULL default '',
`prix_ht` varchar(255) NOT NULL default '',
`poid` varchar(255) NOT NULL default '',
`promo` enum('ok','no') NOT NULL default 'no',
`date_deb` date NOT NULL default '0000-00-00',
`date_fin` date NOT NULL default '0000-00-00',
`remise` decimal(10,0) NOT NULL default '0',
PRIMARY KEY (`id`)
) ENGINE=MyISAM DEFAULT CHARSET=latin1 AUTO_INCREMENT=17 ;
--
-- Contenu de la table `tarif_quantite`
--
INSERT INTO `tarif_quantite` (`id`, `id_produit`, `id_famille`, `quantite`, `prix_ht`, `poid`, `promo`, `date_deb`, `date_fin`, `remise`) VALUES
(1, '1', 1, '100', '13.63', '0.153', 'ok', '0000-00-00', '0000-00-00', 50),
(2, '1', 1, '250', '15.79', '0.359', 'ok', '0000-00-00', '0000-00-00', 0),
(3, '1', 1, '500', '19.93', '0.711', 'no', '0000-00-00', '0000-00-00', 0),
(4, '1', 1, '1000', '25.08', '2.914', 'no', '0000-00-00', '0000-00-00', 0),
(5, '1', 1, '2000', '39.37', '4.291', 'no', '0000-00-00', '0000-00-00', 0),
(6, '1', 1, '3000', '53.66', '2.914', 'no', '0000-00-00', '0000-00-00', 0),
(7, '1', 1, '4000', '67.95', '5.668', 'no', '0000-00-00', '0000-00-00', 0),
(8, '1', 1, '5000', '82.25', '7.045', 'no', '0000-00-00', '0000-00-00', 0),
(9, '1', 1, '7500', '120.53', '10.648', 'no', '0000-00-00', '0000-00-00', 0),
(10, '1', 1, '10000', '156.25', '14.09', 'no', '0000-00-00', '0000-00-00', 0),
(11, '1', 1, '20000', '304.27', '28.18', 'no', '0000-00-00', '0000-00-00', 0),
(12, '2', 1, '300', '40', '', 'no', '0000-00-00', '0000-00-00', 0),
(13, '2', 1, '400', '50', '', 'no', '0000-00-00', '0000-00-00', 0),
(14, '1', 1, '100', '56', '', 'no', '0000-00-00', '0000-00-00', 0),
(15, '3', 1, '500', '56', '', 'no', '0000-00-00', '0000-00-00', 0),
(16, '3', 1, '600', '95', '', 'no', '0000-00-00', '0000-00-00', 0);
[/code]