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 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68
| <?php
function GetSQLValueString($theValue, $theType, $theDefinedValue = "", $theNotDefinedValue = "")
{
$theValue = (!get_magic_quotes_gpc()) ? addslashes($theValue) : $theValue;
switch ($theType) {
case "text":
$theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL";
break;
case "long":
case "int":
$theValue = ($theValue != "") ? intval($theValue) : "NULL";
break;
case "double":
$theValue = ($theValue != "") ? "'" . doubleval($theValue) . "'" : "NULL";
break;
case "date":
$theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL";
break;
case "defined":
$theValue = ($theValue != "") ? $theDefinedValue : $theNotDefinedValue;
break;
}
return $theValue;
}
?>
<?php
if (isset($_SESSION['MM_Username'])) {
mysql_select_db($database_damatmultime, $damatmultime);
$query_commande = sprintf("SELECT id FROM shop_commande WHERE client ='".$_SESSION['MM_Username']."' ORDER BY id DESC");
$commande = mysql_query($query_commande, $damatmultime) or die(mysql_error());
$row_commande = mysql_fetch_assoc($commande);
$totalRows_commande = mysql_num_rows($commande);
mysql_select_db($database_damatmultime, $damatmultime);
$query_panier = sprintf("SELECT shop_panier.*,
shop-jeux.prix_ht,
shop_jeux.prix_ttc,
(shop_jeux.prix_ht*shop_panier.quantite AS total_ht),
(shop_jeux.prix_ttc*shop_panier.quantite AS total_ttc)
FROM shop_panier
INNER JOIN shop_jeux
ON shop_jeux.id=shop_panier.article
WHERE client ='".$_SESSION['MM_Username']."'");
$panier = mysql_query($query_panier, $damatmultime) or die(mysql_error());
$totalRows_panier = mysql_num_rows($panier);
$compteur = 0;
while ($row_panier = mysql_fetch_assoc($panier) and $compteur < $totalRows_panier)
{
$query_ligne_commande = sprintf("INSERT INTO shop_ligne_commande (commande, article, prix_ht, prix_ttc, quantite, total_ht, total_ttc) VALUES (%s; %s, %s, %s, %s, %s, %s)",
GetSQLValueString($row_commande['id'], "int"),
GetSQLValueString($row_panier['article'], "int"),
GetSQLValueString($row_panier['prix_ht'], "double"),
GetSQLValueString($row_panier['prix_ttc'], "double"),
GetSQLValueString($row_panier['quantite'], "int"),
GetSQLValueString($row_panier['total_ht'], "double"),
GetSQLValueString($row_panier['total_ttc'], "double"));
mysql_select_db($database_damatmultime, $damatmultime);
$Result1 = mysql_query($query_ligne_commande, $damatmultime) or die(mysql_error());
$query_suppr_panier = sprintf("DELETE FROM shop_panier WHERE id=%s",
GetSQLValueString($row_panier['id'], "int"));
mysql_select_db($database_damatmultime, $damatmultime);
$Result1 = mysql_query($query_suppr_panier, $damatmultime) or die(mysql_error());
$compteur = $compteur+1;
}
}
?> |
Partager