Forums

view the database in a table

Irate 22 Dec, 2015
Hi Bob,

I have no more quote(), but ....

I can't view the database in a table in front end.

In DB Read:

Action label: lecture
enable: yes
my table name
multi read: yes (i have test no)
enable model id: yes
model id: liste
fields: titre,Image,description
conditions :
<table>
<?php
foreach ($form->data['liste'] as $liste):
?>
<tr><td>Titre: <?php echo $liste['titre'];?></td><td>Titre: <?php echo $liste['Image'];?></td><td>Titre: <?php echo $liste['description'];?></td>
</tr>
<?php
endforeach;
?>
</table>

and... Invalid argument supplied for foreach()

Where is my error?
GreyHead 23 Dec, 2015
Hi Irate,

I guess that at the time this code is running $form->data['liste'] is either empty or doesn't exist. Please drag a Debugger action into the On Submit event, then submit the form and post the debug - including the 'dummy emails' results here.

Note: if you are using the Easy Wizard you can turn on Debug on the Others tab in CFv4 or the Setup tab in CFv5.

Bob
Irate 26 Dec, 2015
Hi Bob,
in french, je suis une buse 😀
Error message in frontend :
Warning: Invalid argument supplied for foreach() in /var/www/hebergement/lamap44/home/sites/administrator/components/com_chronoforms5/chronoforms/actions/db_read/db_read.php(82) : eval()'d code on line 3
Data Array:
Array
(
    [option] => com_chronoforms5
    [chronoform] => affichemateriel
    [Itemid] => 
    [data] => Array
        (
            [0] => Array
                (
                    [id] => 1
                    [titre] => portrait
                    [Image] => 20151213141604_portrait3.jpg
                    [description] => portrait3
                )

            [1] => Array
                (
                    [id] => 2
                    [titre] => corps humain
                    [Image] => 20151218143405_corps_humain_01.jpg
                    [description] => squelette,...
                )

        )

)

Array
(
)

errors:
Array
(
)

Debug Info:
Array
(
    [2] => Array
        (
            [DB Read] => Array
                (
                    [Queries] => Array
                        (
                            [0] => SELECT `data`.`id` AS `data.id`, `data`.`titre` AS `data.titre`, `data`.`Image` AS `data.Image`, `data`.`description` AS `data.description` FROM `ijklr_chronoengine_chronoforms_datatable_newmateriel` AS `data`
                        )

                )

        )

)

In DB Read:

Action label: lecture

enable: yes

my table name: chron.... datatable_newmateriel

multi read: yes

enable model id: yes

model id: data

fields: id,titre,Image,description

conditions :
<table>
<?php
foreach ($form->data['newmateriel'] as $materiel):
?>
<tr><td>Titre: <?php echo $materiel['titre'];?></td><td>Image: <?php echo $materiel['Image'];?></td><td>Description: <?php echo $materiel['description'];?></td>
</tr>
<?php
endforeach;
?>
</table>

I'm going round and round in circles

Bruno
GreyHead 27 Dec, 2015
Hi Bruno,

I can't match the error message you are seeing with the code in the latest version of ChronoForms for Joomla! 2.5. Please will you check which version you have and upgrade if necessary. That may not fix the problem but should help find out what is happening.

Bob
Irate 27 Dec, 2015
I have upgraded it.

Bruno
GreyHead 28 Dec, 2015
Hi Irate,

And what error message do you see now?

Bob
Irate 28 Dec, 2015
Hi Bob,

Warning: Invalid argument supplied for foreach() in /var/www/hebergement/lamap44/home/sites/administrator/components/com_chronoforms5/chronoforms/actions/db_read/db_read.php(85) : eval()'d code on line 3

Bruno
Max_admin 07 Jan, 2016
Answer
it should be
$form->data['data']
and that code should be inside a "custom code" action, not in the "conditions" box.

Regards,
Max
Max, ChronoForms developer
ChronoMyAdmin: Database administration within Joomla, no phpMyAdmin needed.
ChronoMails simplifies Joomla email: newsletters, logging, and custom templates.
Irate 08 Jan, 2016
Thank's Max

It's ok now.

Best regards

Bruno
This topic is locked and no more replies can be posted.