Welcome guest. Before posting on our computer help forum, you must register. Click here it's easy and free.

Author Topic: shopping cart calculate the amount  (Read 25404 times)

0 Members and 1 Guest are viewing this topic.

Justeman

    Topic Starter


    Rookie

    • Experience: Beginner
    • OS: Windows 7
    shopping cart calculate the amount
    « on: August 18, 2014, 02:46:57 AM »
    Hi,
    I have a shopping cart (first script)below is OK, but when I want to make the calculate(second script) the amount,
    it indicate the under last line ( <p><a href="index.php">Home[/url]</p), error is: Parse error: syntax error, unexpected $end in C:\wampserver32\www\sale\votre_panier.php on line 41
    I wish someone can help me to modifiy it.

    first script (it is OK)
    <?php
    session_start();
    require_once 'panier.php';
    $panier = new Panier('produits');
    $listproduit = $panier->getPanier();
    ?>
    <?php  if(!$listproduit){?>
           <p> votre panier est vide </p>
          <?php  } else {?>
          <table border="1" width="50%">
          <tr>
            <td>Name</td>
           <td>Price</td>
           <td>Quantity</td>
             <td>Amount</td>
          </tr>
    <?php foreach($listproduit as $produit) { ?>
       <tr>
          <td><?php print $produit['name'] ?></td>
          <td><?php print $produit['price'] ?></td>
          <td><?php print $produit['quantity'] ?></td>      
       </tr>   
       <?php } ?>
    </table>
    <?php   } ?>
      <p><a href="index.php">Home[/url]</p>

    second script:
    session_start();
    require_once 'panier.php';
    $panier = new Panier('produits');
    $listproduit = $panier->getPanier();
    ?>
    <?php  if(!$listproduit){?>
           <p> votre panier est vide </p>
          <?php  } else {?>
          <table border="1" width="50%">
          <tr>
            <td>Name</td>
           <td>Price</td>
           <td>Quantity</td>
             <td>Amount</td>
          </tr>
           
         <?php
          if(isset($_SESSION['cart'])){
            $sql="SELECT * FROM trybase WHERE name IN (";
              foreach($_SESSION['cart'] as $id =>$value) {
                     $sql.=$id.",";
                 }
             $sql=substr($sql, 0, -1).") ORDER BY name ASC";
            $query=mysql_query($sql);
          while ($produit=mysql_fetch_array($query)){
               ?>
             
    <?php foreach($listproduit as $produit) { ?>
       <tr>
          <td><?php print $produit['name'] ?></td>
          <td><?php print $produit['price'] ?></td>
          <td><?php print $produit['quantity'] ?></td>      
           <td><?php print $_SESSION['cart'][$produit['name']]*$produit['quantity']?>€</td>    
       </tr>   
       <?php } ?>
    </table>
    <?php   } ?>
      <p><a href="index.php">Accueil[/url]</p>

    DaveLembke



      Sage
    • Thanked: 662
    • Certifications: List
    • Computer: Specs
    • Experience: Expert
    • OS: Windows 10
    Re: shopping cart calculate the amount
    « Reply #1 on: August 18, 2014, 07:40:03 AM »
    Looks like the
    Code: [Select]
    </a> end tags are showing up as </url>, is this also this way in your code in which the a href hyperlink end tags should be
    Code: [Select]
    </a>