1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34
| // on recupere le materiel utilisé //
$cout_materiel_total=0;
$mat="";
//while($a<=20) mieux vaut utiliser un for au lieu du while
for ($a=1;$a<=20;a++)
{
if ($_POST['materiel'.$a]!="aucun")
{
// on stocke les variables dans un tableau //
$tab[$a][]=$_POST['materiel'.$a];
$tab[$a][]=$_POST['nombre'.$a];
$tab[$a][]=$_POST['coef_maj'.$a]*$_POST['prix_unit'.$a];
$tab[$a][]=($_POST['coef_maj'.$a]*$_POST['prix_unit'.$a])*$_POST['nombre'.$a];
$tab[$a][]=strtr($_POST['prix_unit'.$a],".,", ".");
$tab[$a][]=$_POST['coef_maj'.$a];
// calcul du cout des materiels //
$cout_materiel_total=$tab[$a][3]+$cout_materiel_total;
}
// on recupere les données du select concernant les affectations //
if (isset($tab[$a]) and isset($tab[$a][1]) and $tab[$a][1]!=0)
{
echo "<tr>";
for ($i=0;$i<=3;$i++)
{
$mat=$tab[$a][$i]."-".$mat;
echo "<td> $tab[$a][$i] </td>";
}
echo "</tr>";
}
} |
Partager