one query - 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 one query.php

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