Buy Now
Sign in

Display records from a table in CFV6 - please help

mstorey , July 30 at 07:38
M
mstorey
Hi
As part of my form, I want to display a user's current bookings.
I have a read data object called read_data24 which has a model name Data24
In the design section I have the following custom code:
<table>​
​ <tr><th>ID</th><th>Type</th></tr>​
​<?php foreach ($this->get ('read_data24') as $d):​
​?>​
​<tr>​
​ <td><?php echo $d['id'];?></td>​
​ <td><?php echo $d['user_id'];?></td>​
​</tr>​
​<?php​
​endforeach;​
​?>​
​</table>
IF I set the read data object to return only the first result, I get that result, but when set to return ALL rows, I dont get anything
I would be very grateful if someone would explain what I am doing wrong - I have read the FAQs and the v6manual.
Here is the result of the debugger showing the Array returned:
Array
(
[read_data24] => Array
(
[log] => Array
(
[0] => SELECT `Data24`.`id` AS `Data24.id`, `Data24`.`user_id` AS `Data24.user_id`, `Data24`.`created` AS `Data24.created`, `Data24`.`modified` AS `Data24.modified`, `Data24`.`asset_owner` AS `Data24.asset_owner`, `Data24`.`type_of_resource` AS `Data24.type_of_resource`, `Data24`.`description` AS `Data24.description`, `Data24`.`asset_id` AS `Data24.asset_id`, `Data24`.`state` AS `Data24.state`, `Data24`.`aid` AS `Data24.aid` FROM `k5jm3_chronoforms_data_add-a-resource` AS `Data24` LIMIT 100;
)

[var] => Array
(
[0] => Array
(
[Data24] => Array
(
[id] => 12
[user_id] => 0
[created] => 2018-07-21 11:09:26
[asset_owner] => Cleeve
[type_of_resource] => OhBots
[description] => A dropcrate of 15 OhBots
[asset_id] => OhBot Crate1
[state] => 0
[aid] => 0
)

)

[1] => Array
(
[Data24] => Array
(
[id] => 13
[user_id] => 0
[created] => 2018-07-21 11:29:35
[asset_owner] => Cleeve
[type_of_resource] => OhBots
[description] => A dropcrate of 15 OhBots
[asset_id] => OhBot3
[state] => 1
[aid] => 0
)

)

[2] => Array
(
[Data24] => Array
(
[id] => 16
[user_id] => 0
[created] => 2018-07-21 21:35:39
[modified] => 2018-07-21 21:36:13
[asset_owner] => Cleeve
[type_of_resource] => iPads
[description] => A dropcrate of 15 iPads
[asset_id] => iPad1
[state] => 1
[aid] => 0
)

)

)

)

)
Many thanks
Michael
C
Crams
Hey, not sure if this works but it's worth trying, use $this->get('read_data24.Data24') since Data24 seems to be the name of the model, the thing is the array for just one result is different than the whole table so you need to be more specific...
healyhatman
$this->get("var name", "default if not found");
Web developer at SkySpider.com.au
I don't work for ChronoEngine but I do accept donations paypal.me/healyhatman
S
stikkimorey
Thank you very much for the help. I ended up using a repeater area for this - I should have read the manual more carefully - I would have found it sooner.