Guest User

Untitled

a guest
Jun 4th, 2013
68
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. <?php
  2. include 'config.php';
  3. db_connect();
  4. check_login();
  5.  
  6. if(!isset($_SESSION['koszyk']))
  7. {
  8.     $_SESSION['koszyk'] = array();
  9. }
  10.  
  11. if(isset($_GET['kup']))
  12. {
  13.  //jeżeli dodajemy jakiœ produkt do koszyka
  14.  $_SESSION['koszyk'][] = $_GET['kup'];
  15.  //przekierowanie z uwzględnieniem nie działajšcych ciasteczek
  16.  header('location: ' .$_SERVER['PHP_SELF']. '?' .SID);
  17.  exit();
  18. }
  19. //sesja przechowywujšca towary
  20. ?>
  21.  
  22. <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1-strict.dtd">
  23. <html xmlns="http://www.w3.org/1999/xhtml">
  24. <head>
  25. <title>Produkty dostępne na naszej stacji </title>
  26. <meta http-enquiv="content-type" content="text/html; charset=iso-8859-2"/>
  27. </head>
  28. <body>
  29. <b> Twój koszyk zawiera: <?php print count($_SESSION['koszyk']); ?> produktów. </b>
  30. <p><a href="koszyk.php">Zobacz koszyk</a></p>
  31. <?php // defninicja tablic z towarami
  32. $towary=array();
  33. $result=mysql_query("SELECT USLUGA_NAZWA_USLUGI as nazwa, USLUGA_CENA_NETTO as cena_netto FROM `USLUGA`");
  34. while($row=mysql_fetch_array($result)) {
  35. $towary[]=array(
  36.     "cena_netto" => $row['cena_netto'],
  37.     "nazwa" => $row['nazwa'],
  38. );
  39. };
  40. ?>
  41. <table border="1">
  42. <thead>
  43. <tr>
  44. <th>Opis towaru</th>
  45. <th>Cena</th>
  46. </tr>
  47. </thead>
  48. <tbody>
  49. <?php
  50. foreach($towary as $index => $towar)
  51. {
  52.     print '<tr><td>' . $towar["nazwa"] . '</td>';
  53.     print '<td>' . number_format($towar["cena_netto"],2) . 'złotych/<td>';
  54.     print '<td><a href=\"".$_SERVER['PHP_SELF']."?kup=$index\">Kup produkt</a></td></tr>';
  55.     }
  56. ?>
  57.     </tbody>
  58.     </table>
  59.     </body>
  60.     </html>
RAW Paste Data