Guest User

Untitled

a guest
Jun 4th, 2013
93
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 FROM `USLUGA`");
  34. $i=0;
  35. while($row=mysql_fetch_array($result)) {
  36. $towary[$i]=$row['USLUGA_NAZWA_USLUGI'];
  37. $i++;
  38. };
  39. ?>
  40. <?php
  41. $ceny=array();
  42. $result2= mysql_query("SELECT USLUGA_CENA_NETTO FROM `USLUGA`");
  43. $k=0;
  44. while($row2=mysql_fetch_array($result2)) {
  45. $ceny[$k]=$row2['USLUGA_CENA_NETTO'];
  46. $k++;
  47. };
  48. var_dump($towary);
  49. var_dump($cena);
  50. ?>
  51. <table border="1">
  52. <thead>
  53. <tr>
  54. <th>Opis towaru</th>
  55. <th>Cena</th>
  56. </tr>
  57. </thead>
  58. <tbody>
  59. <?php
  60. for($i=0; $i<count($towary);$i++)
  61. {
  62.     print '<tr><td>' . $towary[$i] . '</td>';
  63.     print '<td>' . nuber_format($ceny[$i],2) . 'złotych/<td>';
  64.     print '<td><a href=\"".$_SERVER['PHP_SELF']."?kup=$i\">Kup produkt</a></td></tr>';
  65.     }
  66. ?>
  67.     </tbody>
  68.     </table>
  69.     </body>
  70.     </html>
RAW Paste Data