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 35
| $pays = "france";
$totalP = 100000;
//si poids > a la valeur max de la table
$basmaxp = $bdd->prepare("SELECT port, MAX(poids) AS maxpoids FROM frais_port WHERE pays = :pays GROUP BY port");
$basmaxp->execute(array(
'pays'=> $pays
));
if ($basefdp = $basmaxp->fetch()){
echo $FPpoids = $basefdp['maxpoids'];
echo $maxprix = $basefdp['port'];
}
if(isset($FPpoids) AND $totalP > $FPpoids)
{
$FPports = $maxprix ;
$prixfport = number_format($FPports, 2);
$totfport = number_format($FPports, 2). "";
} else {
//calcul en fonction du poids enregistré dans la base
$basfraipo = $bdd->prepare("SELECT port, poids
FROM frais_port
WHERE poids >= :poids AND pays = :pays ORDER BY poids ASC limit 0,1");
$basfraipo->execute(array(
'poids'=> $totalP,
'pays'=> $pays
));
if ($elementfp = $basfraipo->fetch()){
$FPpoids = $elementfp['poids'];
$FPports = $elementfp['port'];
$prixfport = number_format($FPports, 2);
$totfport = number_format($FPports, 2). "";
}
} |
Partager