Guest User

Untitled

a guest
Jun 4th, 2013
9
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. ?>
  49. <table border="1">
  50. <thead>
  51. <tr>
  52. <th>Opis towaru</th>
  53. <th>Cena</th>
  54. </tr>
  55. </thead>
  56. <tbody>
  57. <?php
  58. for($i=0; $i<count($towary);$i++)
  59. {
  60.     print '<tr><td>' . $towary[$i] . '</td>';
  61.     print '<td>' . number_format($ceny[$i],2) . 'złotych/<td>';
  62.         print '<td><a href="'.$_SERVER['PHP_SELF'].'?kup=$i">Kup produkt</a></td></tr>';
  63.     }
  64. ?>
  65.     </tbody>
  66.     </table>
  67.     </body>
  68.     </html>
RAW Paste Data