Visualizzazione dei risultati da 1 a 2 su 2

Discussione: problema carrello

  1. #1

    problema carrello

    Codice PHP:
    <?php
    session_start
    ();
    if (!isset(
    $_SESSION['cart'])) {
      
    $_SESSION['cart'] = array();
    }
    if (isset(
    $_GET['buy'])) {
      
    // Add item to the end of the $_SESSION['cart'] array
      
    $_SESSION['cart'][] = $_GET['buy'];
      
    header('location: ' $_SERVER['PHP_SELF'] . '?' SID);
      exit();
    }
    ?>
    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
        "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
    <html xmlns="http://www.w3.org/1999/xhtml">
    <head>
    <title>Product catalog</title>
    <meta http-equiv="content-type"
        content="text/html; charset=iso-8859-1" />
    </head>
    <body>


    Your shopping cart contains <?php echo count($_SESSION['cart']); ?> items.</p>


    [url="cart.php"]View your cart[/url]</p>
    <?php
    $items 
    = array(
        
    'Canadian-Australian Dictionary',
        
    'As-new parachute (never opened)',
        
    'Songs of the Goldfish (2CD Set)',
        
    'Ending PHP4 (O\'Wroxey Press)');
    $prices = array(24.95100019.9934.95);
    ?>
    <table border="1">
      <thead>
        <tr>
          <th>Item Description</th>
          <th>Price</th>
        </tr>
      </thead>
      <tbody>
    <?php
      
    for ($i 0$i count($items); $i++) {
        echo 
    '<tr>';
        echo 
    '<td>' $items[$i] . '</td>';
        echo 
    '<td>$' number_format($prices[$i], 2) . '</td>';
        echo 
    '<td><a href="' $_SERVER['PHP_SELF'] .
            
    '?buy=' $i '">Buy</a></td>';
        echo 
    '</tr>';
      }
    ?>
      </tbody>
    </table>


    All prices are in imaginary dollars.</p>
    </body>
    </html>
    al posto dell'array come mostro il contenuto di due campi di database?

  2. #2
    sai come connetterti al db? come inviare query SQL e leggere i dati che ritornano i comandi?

Permessi di invio

  • Non puoi inserire discussioni
  • Non puoi inserire repliche
  • Non puoi inserire allegati
  • Non puoi modificare i tuoi messaggi
  •  
Powered by vBulletin® Version 4.2.1
Copyright © 2025 vBulletin Solutions, Inc. All rights reserved.