Guest User

Untitled

a guest
Jun 4th, 2013
47
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. session_start();
  6. if(!isset($_SESSION['koszyk'])){
  7.     $_SESSION['koszyk'] = array();
  8. }
  9. if (isset($_GET['reset']))
  10. {
  11.     unset($_SESSION['koszyk']);
  12.     header('location: ' . $_SERVER['PHP_SELF'] . '?' . SID);
  13.     exit();
  14. }
  15. ?>
  16. <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1-strict.dtd">
  17. <html xmlns="http://www.w3.org/1999/xhtml">
  18. <head>
  19. <title>Twój koszyk zakupów </title>
  20. <meta http-enquiv="content-type" content="text/html; charset=iso-8859-2" />
  21. </head>
  22. <body>
  23. <h1> Twój koszyk z zakupami</h1>
  24. <?php // defninicja tablic z towarami
  25. $result=mysql_query("SELECT USLUGA_NAZWA_USLUGI FROM `USLUGA`");
  26. $i=0;
  27. while($row=mysql_fetch_array($result)) {
  28. $towary[$i]=$row['USLUGA_NAZWA_USLUGI'];
  29. $i++;
  30. };
  31. $result2= mysql_query("SELECT USLUGA_CENA_NETTO FROM `USLUGA`");
  32. $i =0;
  33. while($row=mysql_fetch_array($result2)) {
  34. $ceny[$i]=$row['USLUGA_CENA_NETTO'];
  35. $i++;
  36. };
  37. ?>
  38. <?php // defninicja tablic z towarami
  39.  
  40. $stawka=array();
  41.  
  42. $result3=mysql_query("SELECT USLUGA_STAWKA_USLUGI FROM `USLUGA`");
  43.  
  44. $r=0;
  45.  
  46. while($row3=mysql_fetch_array($result3)) {
  47.  
  48. $stawka[$r]=$row3['USLUGA_STAWKA_USLUGI'];
  49.  
  50. $r++;
  51.  
  52. };
  53. ?>
  54. <table border="1">
  55. <thead>
  56. <tr>
  57. <th>Opis towaru</th>
  58. <th>Cena</th>
  59. <th>Ilosc</th>
  60. <th>Stawka</th>
  61. </tr>
  62. <thead>
  63. <tbody>
  64. <?php
  65. $suma = 0;
  66. for($i=0; $i<count($_SESSION['koszyk']); $i++)
  67. {
  68. echo '<tr>';
  69. echo '<td>'.$towary[$_SESSION['koszyk'][$i]] .'</td>';
  70. echo '<td align="right">';
  71. echo number_format($ceny[$_SESSION['koszyk'][$i]],2);
  72. echo 'złotych</td>';
  73. echo '<td><input type="number" name="nazwa" tabindex="1"  min="1" max="50"/></td>';
  74. echo '<td align="right">';
  75. echo number_format($stawka[$_SESSION['koszyk'][$i]],2);
  76. echo '%</td></tr>';
  77. $ilosc=$_GET['nazwa'];
  78. $suma = $suma + ($ceny[$_SESSION['koszyk'][$i]] * $ilosc)*0.01;
  79. $podatek = $podatek + ($ceny[$_SESSION['koszyk'][$i]]* $stawka[$_SESSION['koszyk'][$i]])*0.01;
  80. }
  81. ?>
  82. </tbody>
  83. <tfoot>
  84. <tr>
  85. <th align="right">Należnośœć: </th><br>
  86. <th align="right"><?php echo number_format($suma,2); ?> złotych.
  87. </th>
  88. <th align="right">Podatek VAT: </th><br>
  89. <th align="right"><?php echo number_format($podatek,2); ?> złotych.
  90. </th>
  91. </tr>
  92. </tfoot>
  93. </table>
  94. <p><a href="towary.php">Kupuj dalej</a> lub też : <a href=<?php echo $_SERVER['PHP_SELF']; ?>?reset=1">Wyczyœć swój koszyk </a></p>
  95. </body>
  96. </html>
RAW Paste Data