# How to display the results of my request on the cakephp 3 view

**URL:** https://discourse.cakephp.org/t/how-to-display-the-results-of-my-request-on-the-cakephp-3-view/7176
**Category:** Need Help
**Created:** [January 27, 2020, 4:00pm UTC](https://discourse.cakephp.org/t/how-to-display-the-results-of-my-request-on-the-cakephp-3-view/7176 "2020-01-27T16:00:07Z")
**Posts on this page:** 4
**Page:** 1

<div class="post-metadata">

### Author: ![schloter](https://avatars.discourse-cdn.com/v4/letter/s/a183cd/32.png) [@schloter](https://discourse.cakephp.org/u/schloter)
#### Post date: [January 27, 2020, 4:00pm UTC](https://discourse.cakephp.org/t/how-to-display-the-results-of-my-request-on-the-cakephp-3-view/7176/1 "2020-01-27T16:00:07Z")

</div>

Hello I have a problHello I have a problem to display the results of my request in cakephp here is the request:em to display the results of my request in cakephp here is the request:

$connection = ConnectionManager::get(‘default’);  
$marches = $connection-\>execute('SELECT COUNT(\*) AS nombre,  
num\_contrat,  
libelle\_marche,  
date\_debut\_marche,  
date\_fin\_marche,  
SUM(montant\_cible),  
SUM(montant\_commande),  
SUM(montant\_receptionne)  
FROM marches  
GROUP BY libelle\_marche  
')-\>fetchAll(‘assoc’);

in my controller  
public function planning()  
{  
$marches = $this-\>Marches-\>getMarche();  
foreach($marches as $marche)  
debug($marche-\>num\_contrat);  
die(‘hi’);  
}

here is the message I have :  
null

[**Notice** (8)](javascript:void(0);): Trying to get property of non-object [**APP/Controller/MarchesController.php** , line **39**]

how to display the result in my view for example I would like to display the value of num\_contrat, nombre …  
thanks for your help

---

<div class="post-metadata">

### Author: ![Zuluru](https://yyz1.discourse-cdn.com/flex029/user_avatar/discourse.cakephp.org/zuluru/32/1230_2.png) [@Zuluru](https://discourse.cakephp.org/u/Zuluru)
#### Post date: [January 27, 2020, 11:21pm UTC](https://discourse.cakephp.org/t/how-to-display-the-results-of-my-request-on-the-cakephp-3-view/7176/2 "2020-01-27T23:21:51Z")

</div>

What’s line 39 of MarchesController.php? We have no idea from what you’ve shown here.

---

<div class="post-metadata">

### Author: ![schloter](https://avatars.discourse-cdn.com/v4/letter/s/a183cd/32.png) [@schloter](https://discourse.cakephp.org/u/schloter)
#### Post date: [January 28, 2020, 9:08am UTC](https://discourse.cakephp.org/t/how-to-display-the-results-of-my-request-on-the-cakephp-3-view/7176/3 "2020-01-28T09:08:16Z")

</div>

Ok line 39 represents : debug($marche-\>num\_contrat.  
to make it simple in my controller I have a function planning:  
public function planning()  
{  
$connection = ConnectionManager::get(‘default’);  
$marches = $connection-\>execute('SELECT COUNT(\*) AS nombre,  
num\_contrat,  
libelle\_marche,  
date\_debut\_marche,  
date\_fin\_marche,  
SUM(montant\_cible),  
SUM(montant\_commande),  
SUM(montant\_receptionne)  
FROM marches  
GROUP BY libelle\_marche  
')-\>fetchAll(‘assoc’);  
foreach($marches as $marche)  
debug($marche);  
die(‘hi’);  
}

when I debug ($marche), I can see the results I want :  
**/src/Controller/MarchesController.php** (line **39** )

[ ‘nombre’ =\> ‘10’,  
‘num\_contrat’ =\> ‘EC3BAC5010’,  
‘libelle\_marche’ =\> ‘AERIEN’,  
‘date\_debut\_marche’ =\> ‘2015-02-02’,  
‘date\_fin\_marche’ =\> ‘2020-01-31’,  
‘SUM(montant\_cible)’ =\> ‘14728500’,  
‘SUM(montant\_commande)’ =\> ‘13347673’,  
‘SUM(montant\_receptionne)’ =\> ‘12443733’ ]

but when I want to recover the value of ‘num\_contrat’ =\> ‘ECBAC5010’ by debug($marche-\> num\_contrat); I have :  
null

[**Notice** (8)](javascript:void(0);): Trying to get property of non-object [**APP/Controller/MarchesController.php** , line **39**]

How to display the values ​​of my request in a view, thanks

---

<div class="post-metadata">

### Author: ![Zuluru](https://yyz1.discourse-cdn.com/flex029/user_avatar/discourse.cakephp.org/zuluru/32/1230_2.png) [@Zuluru](https://discourse.cakephp.org/u/Zuluru)
#### Post date: [January 28, 2020, 3:21pm UTC](https://discourse.cakephp.org/t/how-to-display-the-results-of-my-request-on-the-cakephp-3-view/7176/4 "2020-01-28T15:21:16Z")

</div>

The results show that you have an _array_ of results, not an _object_. Just like the error message would indicate. As such, you’d need to reference the value you’re looking for as `$marche['num_contrat']`.
