# Output value in cakephp

**URL:** <https://discourse.cakephp.org/t/output-value-in-cakephp/6861>\
**Category:** Need Help\
**Created:** [November 8, 2019, 11:57am UTC](https://discourse.cakephp.org/t/output-value-in-cakephp/6861 "2019-11-08T11:57:45Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![Aman](https://avatars.discourse-cdn.com/v4/letter/a/90ced4/32.png) [@Aman](https://discourse.cakephp.org/u/Aman)\
**Post date:** [November 8, 2019, 11:57am UTC](https://discourse.cakephp.org/t/output-value-in-cakephp/6861/1 "2019-11-08T11:57:45Z")

</div>

Good afternoon!  
Tell me how to show the value of a field from another table (has many) when outputting?  
There are two tables: patients and analyzes. I display the data for patients, but in this output, the value of the two fields should be inferred from the analysis table. How to do it?  
Thank you in advance!(has many)

---

<div class="post-metadata">

**Author:** ![jimgwhit](https://yyz1.discourse-cdn.com/flex029/user_avatar/discourse.cakephp.org/jimgwhit/32/378_2.png) [@jimgwhit](https://discourse.cakephp.org/u/jimgwhit)\
**Post date:** [November 9, 2019, 3:26am UTC](https://discourse.cakephp.org/t/output-value-in-cakephp/6861/2 "2019-11-09T03:26:14Z")

</div>

See: [https://book.cakephp.org/3/en/orm/retrieving-data-and-resultsets.html#eager-loading-associations](https://book.cakephp.org/3/en/orm/retrieving-data-and-resultsets.html#eager-loading-associations)

---

<div class="post-metadata">

**Author:** ![Aman](https://avatars.discourse-cdn.com/v4/letter/a/90ced4/32.png) [@Aman](https://discourse.cakephp.org/u/Aman)\
**Post date:** [November 11, 2019, 4:44am UTC](https://discourse.cakephp.org/t/output-value-in-cakephp/6861/3 "2019-11-11T04:44:45Z")

</div>

Good afternoon!  
This is done in the controller, and what needs to be written in the “Template”?

---

<div class="post-metadata">

**Author:** ![dakota](https://yyz1.discourse-cdn.com/flex029/user_avatar/discourse.cakephp.org/dakota/32/1421_2.png) [@dakota](https://discourse.cakephp.org/u/dakota)\
**Post date:** [November 11, 2019, 10:06am UTC](https://discourse.cakephp.org/t/output-value-in-cakephp/6861/4 "2019-11-11T10:06:23Z")

</div>

You should use the association properties. Something like `$patient->analyze->whatever`

---

<div class="post-metadata">

**Author:** ![Aman](https://avatars.discourse-cdn.com/v4/letter/a/90ced4/32.png) [@Aman](https://discourse.cakephp.org/u/Aman)\
**Post date:** [November 11, 2019, 11:03am UTC](https://discourse.cakephp.org/t/output-value-in-cakephp/6861/5 "2019-11-11T11:03:42Z")

</div>

I have two tables “analyzes” (id, number, date, result and patient\_id) and “patients” (last name, first name, birthday, gender).  
My task: in the patient template, derive: for each patient, derive values from the analyzes (date and result).  
How to do it? What needs to be done in the controller and in the patient template?
