Using PHP and MongoClient, I'm trying to figure out how to list users in one organization.
I can list all users from all organizations, but I only want to list users from one organization.
How do I filter the documents like this?
My document structure is simple:
{
"_id" : ObjectId("56fd6a77768d8864028b4578"),
"name" : "Jack Daniels",
"email" : "jackdaniels@janes-jeans.com",
"manager" : "John doe",
"password" : "$2y$10$cec5pzCghhhRdwPVnT/t4.EssfIbqighVqpZSa3jWPRV4gdfXUGDu",
"organization" : "Jane's Jeans"
}
Here is my code where I'm trying to only get results related to one organization:
<optgroup label="Employees">
<?php
$cursor = $collection->find($curr_org);
foreach($cursor as $curr_org) {
echo '<option name="name">';
echo $curr_org['name'];
echo '</option>';
}
?>
</optgroup>
$curr_org contains the organization name.
Removing $curr_org from find() displays all user from all organizations.
Thanks for your help.