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.



Your result can be seen below.

Result of php executing





Full code of two queries.php

  1. <?php
  2.     $cart = $db->query(" SELECT * FROM `{$db_cart}`  WHERE order_userid={$usr["id"]} && order_status='new' ")->fetchAll();
  3.     $total = array();
  4.     foreach ($cart as $v) {
  5.         $total[] = $v["order_cost"];
  6.     }
  7.     $cart_count = $db->query(" SELECT COUNT(*) FROM `{$db_cart}`  WHERE order_userid={$usr["id"]} && order_status='new' ")->fetchColumn();
  8.     $data["count"] = $cart_count;
  9.     $data["total"] = array_sum($total);
  10.     print json_encode($data);
  11.  
File Description
  • two queries
  • PHP Code
  • 07 Jul-2021
  • 465 Bytes
You can Share it: