Connexion établie avec succès.
Fichier de traitement folder
endif ?>
if (($maj==3) || ($maj==4) || ($maj==2)): ?>
if ($maj == 2):
$majcode_escaped = mysqli_real_escape_string($connexion, $majcode);
$result2 = mysqli_query($connexion, "SELECT * FROM parts WHERE numero='$majcode_escaped'");
$xprix = 0;
$majqte = 0 + $majqte;
if ($majqte > 0 && mysqli_num_rows($result2) > 0):
// On sauvegarde le résultat pour l'utiliser plus bas
$row2 = mysqli_fetch_assoc($result2);
$xprix = $row2['prix1'];
if ($row2['prixpromo1'] > 0):
$xprix = $row2['prixpromo1'];
endif;
// Repositionner le pointeur au début au cas où on en a besoin plus bas
mysqli_data_seek($result2, 0);
endif;
$result = mysqli_query($connexion, "SELECT * FROM comparts WHERE ref='$ref_escaped' AND code='$majcode_escaped'");
$num = mysqli_num_rows($result);
if ($num > 0):
$result1 = mysqli_query($connexion, "UPDATE comparts SET qte='$majqte' WHERE code='$majcode_escaped' AND ref='$ref_escaped'");
$result1 = mysqli_query($connexion, "UPDATE comparts SET prix='$xprix' WHERE code='$majcode_escaped' AND ref='$ref_escaped'");
else:
if (mysqli_num_rows($result2) > 0) {
$row2 = mysqli_fetch_assoc($result2);
$xlib = $row2['refmarque'];
$xxarticle = $row2['refarticle'];
$libpars = $row2['presentation'];
$indic4 = $row2['indic4'];
$libpart = $libpars . " " . $indic4 . " ";
} else {
$xlib = ''; $xxarticle = ''; $libpart = '';
}
$libpart_escaped = mysqli_real_escape_string($connexion, $libpart);
$result = mysqli_query($connexion, "INSERT INTO comparts VALUES ('','$ref_escaped','$majcode_escaped','$xlib','$majqte','$xprix','$xxarticle',\"$libpart_escaped\")");
endif;
endif;
// Lecture du panier
$result = mysqli_query($connexion, "SELECT * FROM comparts WHERE ref='$ref_escaped'");
$num = mysqli_num_rows($result);
// nbre de part : panier vide?
$nbpart = 0;
$montant = 0.0;
while ($row = mysqli_fetch_assoc($result)):
$nbpart += $row['qte'];
$xcode = mysqli_real_escape_string($connexion, $row['code']);
$result1 = mysqli_query($connexion, "SELECT * FROM parts WHERE numero='$xcode'");
$num1 = mysqli_num_rows($result1);
if ($num1 < 1):
// pb
$xprix = 0;
else:
$row1 = mysqli_fetch_assoc($result1);
if ($row['qte'] > 0):
$xprix = $row1['prix1'];
if ($row1['prixpromo1'] > 0):
$xprix = $row1['prixpromo1'];
endif;
endif;
endif;
$montant = $montant + $xprix * $row['qte'];
endwhile;
// LE PORT
// ici titre des selections de 1 a x
$titre[99] = "Les Promotions en cours";
$phrase = "1=1"; // Valeur par défaut pour éviter un crash SQL si aucune condition n'est remplie
if ($maj == 3):
// ici les selections de 1 a x
$majcode1 = 0 + $majcrit;
if ($majcode1 > 0):
$phrase = "codselec='" . mysqli_real_escape_string($connexion, $majcode1) . "'";
endif;
// les promotions
if ($majcode1 == 99):
$phrase = "prixpromo1>'0'";
endif;
$titre = isset($titre[$majcode1]) ? $titre[$majcode1] : '';
endif;
if ($maj == 4):
if ($majcrit > -1):
$phrase = "refarticle='" . mysqli_real_escape_string($connexion, $majcrit) . "'";
$titre = " ";
else:
$phrase = " lib LIKE '%" . mysqli_real_escape_string($connexion, $majcrit1) . "%'";
$titre = "Recherche avec : " . $majcrit1;
endif;
endif;
if ($maj == 2):
if ($douvien == 3):
// ici les selections de 1 a x
$majcode1 = 0 + $majcrit;
if ($majcode1 > 0):
$phrase = "codselec='" . mysqli_real_escape_string($connexion, $majcode1) . "'";
endif;
// les promotions
if ($majcode1 == 99):
$phrase = "prixpromo1>'0'";
endif;
$titre = isset($titre[$majcode1]) ? $titre[$majcode1] : '';
endif;
if ($douvien == 4):
if ($majcrit > -1):
$phrase = "refarticle='" . mysqli_real_escape_string($connexion, $majcrit) . "'";
$titre = " ";
else:
$phrase = " lib LIKE '%" . mysqli_real_escape_string($connexion, $majcrit1) . "%'";
$titre = "Mot saisi : " . $majcrit1;
endif;
endif;
endif;
$result = mysqli_query($connexion, "SELECT * FROM parts WHERE $phrase");
$num = mysqli_num_rows($result);
?>
FIN maj 3 4 2 -