IdentifiantMot de passe
Loading...
Mot de passe oublié ?Je m'inscris ! (gratuit)
Navigation

Inscrivez-vous gratuitement
pour pouvoir participer, suivre les réponses en temps réel, voter pour les messages, poser vos propres questions et recevoir la newsletter

PHP & Base de données Discussion :

Panier virtuel


Sujet :

PHP & Base de données

Vue hybride

Message précédent Message précédent   Message suivant Message suivant
  1. #1
    Membre confirmé
    Profil pro
    Inscrit en
    Août 2006
    Messages
    106
    Détails du profil
    Informations personnelles :
    Localisation : France

    Informations forums :
    Inscription : Août 2006
    Messages : 106
    Par défaut Panier virtuel
    bonjour,

    j'ai créé mon propre panier virtuel. Il fonctionne très bien. J'ai simplement un tout petit problème dans mon tableau la partie "article" ne me donne pas le nom de l'article mais le numéro "id" de la base de données.

    Vous faut-il plus d'informations pour m'aider ?

  2. #2
    Modérateur
    Avatar de sabotage
    Homme Profil pro
    Inscrit en
    Juillet 2005
    Messages
    29 208
    Détails du profil
    Informations personnelles :
    Sexe : Homme

    Informations forums :
    Inscription : Juillet 2005
    Messages : 29 208
    Par défaut
    Qu'est ce qui te pose problème exactement ? tu as juste a remplacer le champ "id" par le champ "nom" dans ton affichage.
    N'oubliez pas de consulter les FAQ PHP et les cours et tutoriels PHP

  3. #3
    Membre confirmé
    Profil pro
    Inscrit en
    Août 2006
    Messages
    106
    Détails du profil
    Informations personnelles :
    Localisation : France

    Informations forums :
    Inscription : Août 2006
    Messages : 106
    Par défaut
    oui tu as raison malheureusement cela ne fonctionne pas.

  4. #4
    Rédacteur
    Avatar de RideKick
    Homme Profil pro
    Directeur technique
    Inscrit en
    Septembre 2006
    Messages
    5 914
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Localisation : France, Rhône (Rhône Alpes)

    Informations professionnelles :
    Activité : Directeur technique
    Secteur : High Tech - Produits et services télécom et Internet

    Informations forums :
    Inscription : Septembre 2006
    Messages : 5 914
    Par défaut
    Peut etre qu'un peu de code pourrait nous aider a t'aider ?
    Pas de questions techniques en MP please

    Mon site perso

    Mon profil Viadeo

  5. #5
    Membre confirmé
    Profil pro
    Inscrit en
    Août 2006
    Messages
    106
    Détails du profil
    Informations personnelles :
    Localisation : France

    Informations forums :
    Inscription : Août 2006
    Messages : 106
    Par défaut
    base de données "shop_panier":
    -"id", "int", "unsigned", "auto-increment", "clé primaire"
    -"client", "varchar", "index"
    -"article", "int", "unsigned", "index"
    -"quantité", "int", "unsigned"

    partie du code qui se trouve sur la page de détail des produits:

    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    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
    69
    70
    71
    72
    73
    74
    75
    76
    77
    78
    79
    80
    81
    82
    83
    84
    85
    86
    87
    88
    89
    90
    91
    92
    93
    94
    95
    96
    97
    98
    99
    100
    101
    102
    103
    104
    <?php require_once('Connections/infortech.php'); ?>
    <?php session_start();?>
    <?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;
    }
     
    $editFormAction = $_SERVER['PHP_SELF'];
    if (isset($_SERVER['QUERY_STRING'])) {
      $editFormAction .= "?" . htmlentities($_SERVER['QUERY_STRING']);
    }
     
    if ((isset($_POST["MM_insert"])) && ($_POST["MM_insert"] == "Achat")) {
      $insertSQL = sprintf("INSERT INTO shop_panier (client, article, quantite) VALUES (%s, %s, %s)",
                           GetSQLValueString($_POST['client'], "text"),
                           GetSQLValueString($_POST['article'], "text"),
                           GetSQLValueString($_POST['quantite'], "int"));
     
      mysql_select_db($database_infortech, $infortech);
      $Result1 = mysql_query($insertSQL, $infortech) or die(mysql_error());
     
      $insertGoTo = "produits_detail.php";
      if (isset($_SERVER['QUERY_STRING'])) {
        $insertGoTo .= (strpos($insertGoTo, '?')) ? "&" : "?";
        $insertGoTo .= $_SERVER['QUERY_STRING'];
      }
      header(sprintf("Location: %s", $insertGoTo));
    }
     
    $colname_produits = "0";
    if (isset($_GET['id'])) {
      $colname_produits = (get_magic_quotes_gpc()) ? $_GET['id'] : addslashes($_GET['id']);
    }
    mysql_select_db($database_infortech, $infortech);
    $query_produits = sprintf("SELECT id, reference, rubannu1, rubannu2, titre, prix_ttc, resume, fabricant FROM shop_produits WHERE id = %s", $colname_produits);
    $produits = mysql_query($query_produits, $infortech) or die(mysql_error());
    $row_produits = mysql_fetch_assoc($produits);
    $totalRows_produits = mysql_num_rows($produits);
     
    $idURL_fabricant = "1";
    if (isset($_GET['id'])) {
      $idURL_fabricant = (get_magic_quotes_gpc()) ? $_GET['id'] : addslashes($_GET['id']);
    }
    mysql_select_db($database_infortech, $infortech);
    $query_fabricant = sprintf("SELECT shop_fabricant.* FROM shop_produits INNER JOIN shop_fabricant ON shop_fabricant.id=shop_produits.fabricant WHERE shop_produits.id=%s", $idURL_fabricant);
    $fabricant = mysql_query($query_fabricant, $infortech) or die(mysql_error());
    $row_fabricant = mysql_fetch_assoc($fabricant);
    $totalRows_fabricant = mysql_num_rows($fabricant);
     
    $idURL_rubannu1 = "1";
    if (isset($_GET['id'])) {
      $idURL_rubannu1 = (get_magic_quotes_gpc()) ? $_GET['id'] : addslashes($_GET['id']);
    }
    mysql_select_db($database_infortech, $infortech);
    $query_rubannu1 = sprintf("SELECT shop_categories.* FROM shop_produits INNER JOIN shop_categories ON  shop_categories.id=shop_produits.rubannu1 WHERE shop_produits.id=%s", $idURL_rubannu1);
    $rubannu1 = mysql_query($query_rubannu1, $infortech) or die(mysql_error());
    $row_rubannu1 = mysql_fetch_assoc($rubannu1);
    $totalRows_rubannu1 = mysql_num_rows($rubannu1);
     
    $idURL_rubannu2 = "1";
    if (isset($_GET['id'])) {
      $idURL_rubannu2 = (get_magic_quotes_gpc()) ? $_GET['id'] : addslashes($_GET['id']);
    }
    mysql_select_db($database_infortech, $infortech);
    $query_rubannu2 = sprintf("SELECT shop_sous_categories.* FROM shop_produits INNER JOIN shop_sous_categories ON shop_produits.id=shop_produits.rubannu2 WHERE shop_produits.id=%s", $idURL_rubannu2);
    $rubannu2 = mysql_query($query_rubannu2, $infortech) or die(mysql_error());
    $row_rubannu2 = mysql_fetch_assoc($rubannu2);
    $totalRows_rubannu2 = mysql_num_rows($rubannu2);
     
    $paramclient_panier = "1";
    if (isset($_SESSION['MM_Username'])) {
      $paramclient_panier = (get_magic_quotes_gpc()) ? $_SESSION['MM_Username'] : addslashes($_SESSION['MM_Username']);
    }
    $paramarticle_panier = "1";
    if (isset($_GET['id'])) {
      $paramarticle_panier = (get_magic_quotes_gpc()) ? $_GET['id'] : addslashes($_GET['id']);
    }
    mysql_select_db($database_infortech, $infortech);
    $query_panier = sprintf("SELECT id, client, quantite+1 AS quantite FROM shop_panier WHERE client = '%s' AND article = %s", $paramclient_panier,$paramarticle_panier);
    $panier = mysql_query($query_panier, $infortech) or die(mysql_error());
    $row_panier = mysql_fetch_assoc($panier);
    $totalRows_panier = mysql_num_rows($panier);
    ?>
    partie du code de la page panier:
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    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
    69
    70
    71
    72
    73
    74
    75
    76
    77
    78
    79
    80
    81
    82
    83
    84
    85
    86
    87
    88
    89
    90
    91
    92
    93
    94
    95
    96
    97
    98
    99
    100
    101
    102
    103
    104
    105
    106
    107
    108
    109
    110
    111
    112
    113
    114
    115
    116
    117
    118
    119
    120
    121
    122
    123
    124
    125
    126
    127
    128
    129
    130
    131
    <?php require_once('../Connections/infortech.php'); ?>
    <?php require_once('../Connections/infortech.php'); ?>
    <?php
    session_start();
    $MM_authorizedUsers = "";
    $MM_donotCheckaccess = "true";
     
    // *** Restrict Access To Page: Grant or deny access to this page
    function isAuthorized($strUsers, $strGroups, $UserName, $UserGroup) { 
      // For security, start by assuming the visitor is NOT authorized. 
      $isValid = False; 
     
      // When a visitor has logged into this site, the Session variable MM_Username set equal to their username. 
      // Therefore, we know that a user is NOT logged in if that Session variable is blank. 
      if (!empty($UserName)) { 
        // Besides being logged in, you may restrict access to only certain users based on an ID established when they login. 
        // Parse the strings into arrays. 
        $arrUsers = Explode(",", $strUsers); 
        $arrGroups = Explode(",", $strGroups); 
        if (in_array($UserName, $arrUsers)) { 
          $isValid = true; 
        } 
        // Or, you may restrict access to only certain users based on their username. 
        if (in_array($UserGroup, $arrGroups)) { 
          $isValid = true; 
        } 
        if (($strUsers == "") && true) { 
          $isValid = true; 
        } 
      } 
      return $isValid; 
    }
     
    $MM_restrictGoTo = "../login.php";
    if (!((isset($_SESSION['MM_Username'])) && (isAuthorized("",$MM_authorizedUsers, $_SESSION['MM_Username'], $_SESSION['MM_UserGroup'])))) {   
      $MM_qsChar = "?";
      $MM_referrer = $_SERVER['PHP_SELF'];
      if (strpos($MM_restrictGoTo, "?")) $MM_qsChar = "&";
      if (isset($QUERY_STRING) && strlen($QUERY_STRING) > 0) 
      $MM_referrer .= "?" . $QUERY_STRING;
      $MM_restrictGoTo = $MM_restrictGoTo. $MM_qsChar . "accesscheck=" . urlencode($MM_referrer);
      header("Location: ". $MM_restrictGoTo); 
      exit;
    }
    ?>
    <?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;
    }
     
    $editFormAction = $_SERVER['PHP_SELF'];
    if (isset($_SERVER['QUERY_STRING'])) {
      $editFormAction .= "?" . htmlentities($_SERVER['QUERY_STRING']);
    }
     
    if ((isset($_POST["MM_update"])) && ($_POST["MM_update"] == "quantite")) {
      $updateSQL = sprintf("UPDATE shop_panier SET client=%s, article=%s, quantite=%s WHERE id=%s",
                           GetSQLValueString($_POST['client'], "text"),
                           GetSQLValueString($_POST['article'], "int"),
                           GetSQLValueString($_POST['quantite'], "int"),
                           GetSQLValueString($_POST['article'], "int"));
     
      mysql_select_db($database_infortech, $infortech);
      $Result1 = mysql_query($updateSQL, $infortech) or die(mysql_error());
     
      $updateGoTo = "panier.php";
      if (isset($_SERVER['QUERY_STRING'])) {
        $updateGoTo .= (strpos($updateGoTo, '?')) ? "&" : "?";
        $updateGoTo .= $_SERVER['QUERY_STRING'];
      }
      header(sprintf("Location: %s", $updateGoTo));
    }
     
    if ((isset($_POST["MM_insert"])) && ($_POST["MM_insert"] == "validation")) {
      $insertSQL = sprintf("INSERT INTO shop_commande (`date`, total_ht, total_ttc) VALUES (%s, %s, %s)",
                           GetSQLValueString($_POST['date'], "date"),
                           GetSQLValueString($_POST['total_ht'], "double"),
                           GetSQLValueString($_POST['total_ttc'], "double"));
     
      mysql_select_db($database_infortech, $infortech);
      $Result1 = mysql_query($insertSQL, $infortech) or die(mysql_error());
     
      $insertGoTo = "traitement_commande.php";
      if (isset($_SERVER['QUERY_STRING'])) {
        $insertGoTo .= (strpos($insertGoTo, '?')) ? "&" : "?";
        $insertGoTo .= $_SERVER['QUERY_STRING'];
      }
      header(sprintf("Location: %s", $insertGoTo));
    }
     
    $paramclient_panier = "1";
    if (isset($_SESSION['MM_Username'])) {
      $paramclient_panier = (get_magic_quotes_gpc()) ? $_SESSION['MM_Username'] : addslashes($_SESSION['MM_Username']);
    }
    mysql_select_db($database_infortech, $infortech);
    $query_panier = sprintf("SELECT shop_panier.*, shop_produits.titre, shop_produits.prix_ttc, (shop_produits.prix_ttc*shop_panier.quantite) AS total_ttc, (shop_produits.prix_ht*shop_panier.quantite) AS total_ht FROM shop_panier INNER JOIN shop_produits ON shop_panier.article=shop_produits.id WHERE shop_panier.client = '%s'", $paramclient_panier);
    $panier = mysql_query($query_panier, $infortech) or die(mysql_error());
    $row_panier = mysql_fetch_assoc($panier);
    $totalRows_panier = mysql_num_rows($panier);
     
    $paramclient_total = "0";
    if (isset($_SESSION['MM_Username'])) {
      $paramclient_total = (get_magic_quotes_gpc()) ? $_SESSION['MM_Username'] : addslashes($_SESSION['MM_Username']);
    }
    mysql_select_db($database_infortech, $infortech);
    $query_total = sprintf("SELECT now() AS date, SUM(shop_panier.quantite*shop_produits.prix_ttc) AS total_ttc, SUM(shop_panier.quantite*shop_produits.prix_ht) AS total_ht FROM shop_panier INNER JOIN shop_produits ON shop_produits.id=shop_panier.article WHERE shop_panier.client = '%s' GROUP BY shop_panier.client", $paramclient_total);
    $total = mysql_query($query_total, $infortech) or die(mysql_error());
    $row_total = mysql_fetch_assoc($total);
    $totalRows_total = mysql_num_rows($total);
     session_start();?>

  6. #6
    Rédacteur
    Avatar de RideKick
    Homme Profil pro
    Directeur technique
    Inscrit en
    Septembre 2006
    Messages
    5 914
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Localisation : France, Rhône (Rhône Alpes)

    Informations professionnelles :
    Activité : Directeur technique
    Secteur : High Tech - Produits et services télécom et Internet

    Informations forums :
    Inscription : Septembre 2006
    Messages : 5 914
    Par défaut
    Semblerait que dans ta base tu n'ai pas de champs contenant le libelle de l'article ....
    Pas de questions techniques en MP please

    Mon site perso

    Mon profil Viadeo

Discussions similaires

  1. Panier virtuel comment en créer un ?
    Par sigap dans le forum Langage
    Réponses: 1
    Dernier message: 07/08/2006, 05h41
  2. Panier virtuel need Help!!
    Par louli_computing dans le forum EDI, CMS, Outils, Scripts et API
    Réponses: 7
    Dernier message: 12/06/2006, 13h53
  3. [Tableaux] panier virtuel
    Par Invité dans le forum Langage
    Réponses: 12
    Dernier message: 26/02/2006, 15h33
  4. Script panier virtuel
    Par chodaboy34 dans le forum Langage
    Réponses: 3
    Dernier message: 02/11/2005, 17h49
  5. panier virtuel
    Par jive dans le forum ASP
    Réponses: 5
    Dernier message: 23/08/2005, 18h42

Partager

Partager
  • Envoyer la discussion sur Viadeo
  • Envoyer la discussion sur Twitter
  • Envoyer la discussion sur Google
  • Envoyer la discussion sur Facebook
  • Envoyer la discussion sur Digg
  • Envoyer la discussion sur Delicious
  • Envoyer la discussion sur MySpace
  • Envoyer la discussion sur Yahoo