# PHP and HTML Tables

**URL:** <https://www.phphelp.com/t/php-and-html-tables/25782>\
**Category:** HTML & CSS\
**Created:** [March 17, 2017, 3:25pm UTC](https://www.phphelp.com/t/php-and-html-tables/25782 "2017-03-17T15:25:54Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![nnichol8](https://www.phphelp.com/letter_avatar_proxy/v4/letter/n/fbc32d/32.png) [@nnichol8](https://www.phphelp.com/u/nnichol8)\
**Post date:** [March 17, 2017, 3:25pm UTC](https://www.phphelp.com/t/php-and-html-tables/25782/1 "2017-03-17T15:25:54Z")

</div>

I am trying to pull data from a database and display it in a table using a PHP foreach loop. This is successful. But I need to pull data from multiple database tables, forcing me to use multiple foreach loops to create one HTML table. Is this possible? Nesting the foreach loops is not working (displays error) and not nesting them puts my data from the second foreach loop under my first HTML table, not in it.

---

<div class="post-metadata">

**Author:** ![benanamen](https://www.phphelp.com/user_avatar/www.phphelp.com/benanamen/32/287_2.png) [@benanamen](https://www.phphelp.com/u/benanamen)\
**Post date:** [March 17, 2017, 3:30pm UTC](https://www.phphelp.com/t/php-and-html-tables/25782/2 "2017-03-17T15:30:39Z")

</div>

You need a proper query, not multiple foreach loops.

---

<div class="post-metadata">

**Author:** ![nnichol8](https://www.phphelp.com/letter_avatar_proxy/v4/letter/n/fbc32d/32.png) [@nnichol8](https://www.phphelp.com/u/nnichol8)\
**Post date:** [March 17, 2017, 4:48pm UTC](https://www.phphelp.com/t/php-and-html-tables/25782/3 "2017-03-17T16:48:19Z")

</div>

Thanks for your reply. I am using FileMaker as the database, and I am not sure how familiar you are with it, but the only way to query data from each table is to use a foreach and you can only grab one table at a time. In this lies my problem…
