Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- //This is the functions.php file
- //function pf_validate_number($value, $redirect) {
- // if(isset($value)) {
- // if(!is_numeric($value)) {
- // header('Location: ' . $redirect);
- // }
- // else {
- // $final = $value;
- // }
- // }
- // else {
- // $final = 0;
- // }
- // return $final;
- //}
- function showcart() {
- if($_SESSION['ordernum']) { //20
- if($_SESSION['loggedin']) {
- $query = "SELECT id, status FROM orders WHERE customer_id = '" . $_SESSION['userid'] . "' AND status < 2";
- echo $query;
- $result = mysqli_query($dbc, $query);
- $row = mysqli_fetch_array($result);
- $queryi = "SELECT products.*, orderitems.*, orderitems.id AS itemid FROM products, orderitems WHERE orderitems.product_id = " .
- "products.id AND order_id = '" . $row['id'] . "'";
- $resulti = mysqli_query($dbc, $queryi);
- $numrowsi = mysqli_num_rows($resulti);
- }
- else {
- $query = "SELECT id, status FROM orders WHERE session = '" . session_id() . "' AND status < 2";
- $result = mysqli_query($dbc, $query);
- $row = mysqli_fetch_array($result);
- $queryi = "SELECT products.*, orderitems.*, orderitems.id AS itemid FROM products, orderitems WHERE orderitems.product_id = " .
- "products.id AND order_id = '" . $row['id'] . "'";
- $resulti = mysqli_query($dbc, $queryi);
- $numrowsi = mysqli_num_rows($resulti);
- } //40
- }
- else {
- $numrowsi = 0;
- }
- if($numrowsi == 0) {
- echo 'You have not added anything to your shopping cart yet.';
- }
- else {
- echo '<table cellpadding="10">';
- echo '<tr>';
- echo '<td></td>';
- echo '<td><strong>Item</strong></td>';
- echo '<td><strong>Quantity</strong></td>';
- echo '<td><strong>Unit Price</strong></td>';
- echo '<td><strong>Total Price</strong></td>';
- echo '<td></td>';
- echo '</tr>';
- while($rowi = mysqli_fetch_array($resulti)) { //60
- $quantitytotal = $rowsi['price'] * $rowsi['quantity'];
- echo '<tr>';
- if(empty($rowi['image'])) {
- echo '<td><img src="images/dummy.jpg"></td>';
- }
- else {
- echo '<td><img src="images/' . $rowi['image'] . '"></td>';
- }
- echo '<td>' . $rowi['name'] . '</td>';
- echo '<td>' . $rowi['quantity'] . '</td>';
- echo '<td><strong>£' . sprintf('%.2f', $quantitytotal) . '</strong></td>';
- echo '<td>[<a href="' . $config_basedir . 'delete.php?id=' . $rowi['itemid'] . '">X</a>]</td>';
- echo '</tr>';
- $total = $total + $quantitytotal;
- $queryt = "UPDATE orders SET total = '" . $_SESSION['ordernum'] . "'";
- $resultt = mysqli_query($dbc, $queryt);
- } //80
- echo '<tr>';
- echo '<td></td>';
- echo '<td></td>';
- echo '<td></td>';
- echo '<td>TOTAL</td>';
- echo '<td><strong>£' . sprintf('%.2f', $total) . '</strong></td>';
- echo '<td></td>';
- echo '</tr>';
- echo '</table>';
- echo '<p><a href="checkoutaddress.php">Go to the checkout</a></p>';
- }
- }
- ?>
Add Comment
Please, Sign In to add comment