未显示MongoDB数据

时间:2019-02-22 08:03:28

标签: php arrays mongodb echo

我有一个名为 order 的mongoDB集合。我正在尝试获取当前已登录客户的所有订单详细信息。我正在使用客户电子邮件作为已登录用户的参考。这一行,回显“ email是”。$ email;正确显示电子邮件。但是,我无法显示其他数据。你能帮我吗?

<?php
$mongoClient = new MongoClient("mongodb://localhost:27017");
$db = $mongoClient->commerce;

$email = filter_input(INPUT_POST, "email", FILTER_SANITIZE_STRING);
echo "email is ".$email;
$findCriteria = [
     ["customer_email" => $email] 
];
$cursor = $db->order->find($findCriteria);
echo "<h1>Order History</h1>";
foreach ($cursor as $ord) {
     $email = $ord['customer_email'];
    /*  $price = $cust['cost'];   
     $products = $cust['products'];*/
      echo "test";
     echo "email is ".$email;
   /*echo "<br>";
   echo "email is ".$price;
   echo "<br>";
   echo "email is ".$products;
   echo "<br>";  */ 
}

order collection on mongodb

0 个答案:

没有答案