-
Notifications
You must be signed in to change notification settings - Fork 1
/
qty_total.php
42 lines (28 loc) · 955 Bytes
/
qty_total.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
<?php
session_start();
if(isset($_SESSION['u_name'])){
$us_name= $_SESSION['u_name'] ;
require_once "connect.php";
//Cart QUANTITY Calculation, Created on 30-03-2018, Prabhat Chandra
$sql = $conn->query("SELECT user_name, SUM(u_qty) AS tt_qty
FROM u_cart
GROUP BY user_name = '$us_name'
;")
or die(mysqli_error($conn)) ;
while($tq = $sql->fetch_array()){
$totalqty = $tq['tt_qty'];
//echo $totalqty;
$conn->query("REPLACE INTO `cart_t_q` VALUES( '$us_name', '$totalqty' )") or die(mysqli_error($conn));
}
//Redirection while checking query error, 10-04-2018, Prabhat Chandra
if (!$sql) {
header('Location: error.php', TRUE, 303);
die('Invalid query: ' . mysql_error());
} else {
header('Location: cart.php', TRUE, 303);
die('Success');
}
} else{
header('Location: login.php');
}
?>