Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- include 'config.php';
- db_connect();
- check_login();
- if(!isset($_SESSION['koszyk']))
- {
- $_SESSION['koszyk'] = array();
- }
- if(isset($_GET['kup']))
- {
- //jeżeli dodajemy jaki produkt do koszyka
- $_SESSION['koszyk'][] = $_GET['kup'];
- //przekierowanie z uwzględnieniem nie działajšcych ciasteczek
- header('location: ' .$_SERVER['PHP_SELF']. '?' .SID);
- exit();
- }
- //sesja przechowywujšca towary
- ?>
- <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1-strict.dtd">
- <html xmlns="http://www.w3.org/1999/xhtml">
- <head>
- <title>Produkty dostępne na naszej stacji </title>
- <meta http-enquiv="content-type" content="text/html; charset=iso-8859-2"/>
- </head>
- <body>
- <b> Twój koszyk zawiera: <?php print count($_SESSION['koszyk']); ?> produktów. </b>
- <p><a href="koszyk.php">Zobacz koszyk</a></p>
- <?php // defninicja tablic z towarami
- $towary=array();
- $result=mysql_query("SELECT USLUGA_NAZWA_USLUGI as nazwa, USLUGA_CENA_NETTO as cena_netto FROM `USLUGA`");
- while($row=mysql_fetch_array($result)) {
- $towary[]=array(
- "cena_netto" => $row['cena_netto'],
- "nazwa" => $row['nazwa'],
- );
- };
- ?>
- <table border="1">
- <thead>
- <tr>
- <th>Opis towaru</th>
- <th>Cena</th>
- </tr>
- </thead>
- <tbody>
- <?php
- foreach($towary as $index => $towar)
- {
- print '<tr><td>' . $towar["nazwa"] . '</td>';
- print '<td>' . number_format($towar["cena_netto"],2) . 'złotych/<td>';
- print '<td><a href=\"".$_SERVER['PHP_SELF']."?kup=$index\">Kup produkt</a></td></tr>';
- }
- ?>
- </tbody>
- </table>
- </body>
- </html>
RAW Paste Data