1.

Solve : shopping cart?

Answer»

Hi,
my shopping cart has problem, it cannot retain the input QUANTITY and the product's name from DB.
the display cannot show neither the quantity nor the product's name from DB, do someone can help me please !

product.php
try {
    $conn = new PDO("mysql:host=$host;dbname=$dbname", $username, $password, array( PDO::MYSQL_ATTR_INIT_COMMAND => "SET NAMES utf8"));
   
             $sql = 'SELECT name,                   
               price

            FROM MUSHROOM';
 
    $q = $conn->query($sql);
    $q->setFetchMode(PDO::FETCH_ASSOC);
     
} catch (PDOException $pe) {
    die("Could not connect to the database $dbname :" . $pe->getMessage());
}
?>
   
            fetch()): ?>
             
           
           



addcart.php
   session_start();
   if(isset($_SESSION['panier'])){
      $panier=$_SESSION['panier'];
   }
   else{
      $panier=array();
      
   }
   $index=count($panier);
   $panier[$index]['name']=$_POST['name'];
   $panier[$index]['price']=$_POST['price'];
   $panier[$index]['quantity']=$_POST['quantity'];
   $_SESSION['panier']=$panier;
   header("LOCATION:index.php?")
   
?>


panier.php
    $panier=$_SESSION['panier'];
   
?>

PRODUITPRICEQUANTITY
cancel[/url]
Total:
   
To get any help you are going to need to give a lot more information including how the database is structured, any errors you are get.etc.  Remember, we have no idea how your APPLICATION is built or how it works.my data base:
name: varchar 100 non null
price: float 10  non nullThat is still not nearly enough information...  We still have no idea how the rest of your system is built, what errors you are getting.etc.the rest script:

  index.php   
     
     
     
   
     
   
                 if(isset($_GET['panier']))                    
         require_once('panier.php');
         
         else
          require_once('product.php');    
     ?>
       
   


Discussion

No Comment Found