diff options
Diffstat (limited to 'lib')
-rw-r--r-- | lib/login.php | 7 |
1 files changed, 4 insertions, 3 deletions
diff --git a/lib/login.php b/lib/login.php index 0683031..05caf17 100644 --- a/lib/login.php +++ b/lib/login.php @@ -39,9 +39,10 @@ function check_login($username, $password) { } function get_cart_count() { - global $username, $cursor; - $statement = $cursor->prepare("select sum(cart.count) as count from cart join user on user.id = cart.user join product on product.id = cart.product where user.name = ?"); - $statement->bind_param("s", $username); + global $user_id, $cursor; + if (!$user_id) return 0; + $statement = $cursor->prepare("select ifnull(sum(count), 0) as count from webs.orderproduct where `order` = webs.cart(?)"); + $statement->bind_param("i", $user_id); if (!$statement->execute()) return 0; $res = $statement->get_result(); if (!mysqli_num_rows($res)) return 0; |