0

I would like to take the raw data i am receiving from a mongoDB query into a table only using select data from each document that is returned from the query.

RAW data as seen directly on the html page after being retrieved with under $search.

array(3) { ["_id"]=> int(100000005) ["dclass"]=> string(15) "Distributed" ["fields"]=> array(114) { ["Name"]=> array(1) { ["_0"]=> string(7) "Testing" } ["NameState"]=> array(1) { ["_0"]=> string(7) "PENDING" }

The data i need into the table is the Name and the _id

here is what i currently have.

            foreach ($SEARCH as $row) {
                echo "<tr>";
                echo "<td>" . $row['_id'] . "</td>";
                echo "<td>" . $row['Name'] . "</td>"; 
             echo "</tr>";
            }

            echo "</table>";

1 Answer 1

1

The Name filed is nested. Try this.

<?php

foreach ($SEARCH as $row) {
    echo "<tr>";
    echo "<td>" . $row['_id'] . "</td>";
    echo "<td>" . $row['fields']['Name']['_0'] . "</td>";
    echo "</tr>";
}
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.