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 FROM `USLUGA`");
- $i=0;
- while($row=mysql_fetch_array($result)) {
- $towary[$i]=$row['USLUGA_NAZWA_USLUGI'];
- $i++;
- };
- ?>
- <?php
- $ceny=array();
- $result2= mysql_query("SELECT USLUGA_CENA_NETTO FROM `USLUGA`");
- $k=0;
- while($row2=mysql_fetch_array($result2)) {
- $ceny[$k]=$row2['USLUGA_CENA_NETTO'];
- $k++;
- };
- ?>
- <table border="1">
- <thead>
- <tr>
- <th>Opis towaru</th>
- <th>Cena</th>
- </tr>
- </thead>
- <tbody>
- <?php
- for($i=0; $i<count($towary);$i++)
- {
- print '<tr><td>' . $towary[$i] . '</td>';
- print '<td>' . number_format($ceny[$i],2) . 'złotych/<td>';
- print '<td><a href="'.$_SERVER['PHP_SELF'].'?kup=$i">Kup produkt</a></td></tr>';
- }
- ?>
- </tbody>
- </table>
- </body>
- </html>
RAW Paste Data