Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- include 'config.php';
- db_connect();
- check_login();
- session_start();
- if(!isset($_SESSION['koszyk'])){
- $_SESSION['koszyk'] = array();
- }
- if (isset($_GET['reset']))
- {
- unset($_SESSION['koszyk']);
- header('location: ' . $_SERVER['PHP_SELF'] . '?' . SID);
- exit();
- }
- ?>
- <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1-strict.dtd">
- <html xmlns="http://www.w3.org/1999/xhtml">
- <head>
- <title>Twój koszyk zakupów </title>
- <meta http-enquiv="content-type" content="text/html; charset=iso-8859-2" />
- </head>
- <body>
- <h1> Twój koszyk z zakupami</h1>
- <?php // defninicja tablic z towarami
- $result=mysql_query("SELECT USLUGA_NAZWA_USLUGI FROM `USLUGA`");
- $i=0;
- while($row=mysql_fetch_array($result)) {
- $towary[$i]=$row['USLUGA_NAZWA_USLUGI'];
- $i++;
- };
- $result2= mysql_query("SELECT USLUGA_CENA_NETTO FROM `USLUGA`");
- $i =0;
- while($row=mysql_fetch_array($result2)) {
- $ceny[$i]=$row['USLUGA_CENA_NETTO'];
- $i++;
- };
- ?>
- <?php // defninicja tablic z towarami
- $stawka=array();
- $result3=mysql_query("SELECT USLUGA_STAWKA_USLUGI FROM `USLUGA`");
- $r=0;
- while($row3=mysql_fetch_array($result3)) {
- $stawka[$r]=$row3['USLUGA_STAWKA_USLUGI'];
- $r++;
- };
- ?>
- <table border="1">
- <thead>
- <tr>
- <th>Opis towaru</th>
- <th>Cena</th>
- <th>Ilosc</th>
- <th>Stawka</th>
- </tr>
- <thead>
- <tbody>
- <?php
- $suma = 0;
- for($i=0; $i<count($_SESSION['koszyk']); $i++)
- {
- echo '<tr>';
- echo '<td>'.$towary[$_SESSION['koszyk'][$i]] .'</td>';
- echo '<td align="right">';
- echo number_format($ceny[$_SESSION['koszyk'][$i]],2);
- echo 'złotych</td>';
- echo '<td><input type="number" name="nazwa" tabindex="1" min="1" max="50"/></td>';
- echo '<td align="right">';
- echo number_format($stawka[$_SESSION['koszyk'][$i]],2);
- echo '%</td></tr>';
- $ilosc=$_GET['nazwa'];
- $suma = $suma + ($ceny[$_SESSION['koszyk'][$i]] * $ilosc)*0.01;
- $podatek = $podatek + ($ceny[$_SESSION['koszyk'][$i]]* $stawka[$_SESSION['koszyk'][$i]])*0.01;
- }
- ?>
- </tbody>
- <tfoot>
- <tr>
- <th align="right">Należność: </th><br>
- <th align="right"><?php echo number_format($suma,2); ?> złotych.
- </th>
- <th align="right">Podatek VAT: </th><br>
- <th align="right"><?php echo number_format($podatek,2); ?> złotych.
- </th>
- </tr>
- </tfoot>
- </table>
- <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>
- </body>
- </html>
RAW Paste Data