two queries - PHP Online
Form of PHP Sandbox
Enter Your PHP code here for testing/debugging in the Online PHP Sandbox. As in the usual PHP files, you can also add HTML, but do not forget to add the tag <?php
in the places where the PHP script should be executed.
Result of php executing
Full code of two queries.php
- <?php
- $cart = $db->query(" SELECT * FROM `{$db_cart}` WHERE order_userid={$usr["id"]} && order_status='new' ")->fetchAll();
- $total = array();
- foreach ($cart as $v) {
- $total[] = $v["order_cost"];
- }
- $cart_count = $db->query(" SELECT COUNT(*) FROM `{$db_cart}` WHERE order_userid={$usr["id"]} && order_status='new' ")->fetchColumn();
- $data["count"] = $cart_count;
- $data["total"] = array_sum($total);
- print json_encode($data);