Guest User

Untitled

a guest
Jun 4th, 2013
29
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. <table border="1">
  39. <thead>
  40. <tr>
  41. <th>Opis towaru</th>
  42. <th>Cena</th>
  43. </tr>
  44. <thead>
  45. <tbody>
  46. <?php
  47. $suma = 0;
  48. for($i=0; $i<count($_SESSION['koszyk']); $i++)
  49. {
  50. echo '<tr>';
  51. echo '<td>'.$towary[$_SESSION['koszyk'][$i]] .'</td>';
  52. echo '<td align="right">';
  53. echo number_format($ceny[$_SESSION['koszyk'][$i]],2);
  54. echo 'złotych</td></tr>';
  55. $suma = $suma + $ceny[$_SESSION['koszyk'][$i]];
  56. }
  57. ?>
  58. </tbody>
  59. <tfoot>
  60. <tr>
  61. <th align="right">Należnośœć: </th><br>
  62. <th align="right"><?php echo number_format($suma,2); ?> złotych.
  63. </th>
  64. </tr>
  65. </tfoot>
  66. </table>
  67. <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>
  68. </body>
  69. </html>
RAW Paste Data