Forums

Showing data from database

vismay 22 Jun, 2017
Hello,

in chronoform 5 I was using this code:

<?php
    echo '<table cellspacing="2" cellpadding="2"><tr><th>Nome</th><th>Data di nascita</th><th>Cittadinanza</th><th>Luogo di nascita</th><th>Bottone</th></tr>';
    foreach ($form->data['Data_riepilogo'] as $d ) {
      echo "<tr><td>{$d['cognome']}{$d['nome']}</td><td>{$d['data_nascita']}</td><td>{$d['cittadinanza']}</td><td>{$d['comune']}</td><td>Bottone</td></tr>";
    }
    echo '</table>';
    ?>


$form->data['Data_riepilogo'] is the model name in a read data event.

This is the debug:

Array
(
    [read_data69] => Array
        (
            [log] => Array
                (
                    [0] => SELECT COUNT(`Data_riepilogo`.`key`) AS `Data_riepilogo.count` FROM `le7yz_cf_capo` AS `Data_riepilogo` WHERE `Data_riepilogo`.`capo` LIKE '%kljjkljkh_22-6-2017%';
                    [1] => SELECT `Data_riepilogo`.`cognome` AS `Data_riepilogo.cognome`, `Data_riepilogo`.`nome` AS `Data_riepilogo.nome`, `Data_riepilogo`.`data_nascita` AS `Data_riepilogo.data_nascita`, `Data_riepilogo`.`cittadinanza` AS `Data_riepilogo.cittadinanza`, `Data_riepilogo`.`comune` AS `Data_riepilogo.comune` FROM `le7yz_cf_capo` AS `Data_riepilogo` WHERE `Data_riepilogo`.`capo` LIKE '%kljjkljkh_22-6-2017%' LIMIT 30;
                )

            [var] => Array
                (
                    [kljjkljkh] => jkhkjhkj
                    [pppp] => pppp
                )

        )

)



It's something different in CF6?
GreyHead 22 Jun, 2017
Hi vismay,

Max has changed $form->data to $this->data

There may be other changes as well, but start by testing that one.

Bob
vismay 22 Jun, 2017
Which is right?

$this->data['Data_riepilogo']
or
$this->data("Data_riepilogo", "default value")

I'm trying both but with no results...
Max_admin 22 Jun, 2017
Hi vismay,

If you need a field value under a model then please use this:
$this->data("model.field", "default value");


Best regards,
Max
Max, ChronoForms developer
ChronoMyAdmin: Database administration within Joomla, no phpMyAdmin needed.
ChronoMails simplifies Joomla email: newsletters, logging, and custom templates.
vismay 22 Jun, 2017
Not working...

See the read data debug:

Array
(
    [read_data69] => Array
        (
            [log] => Array
                (
                    [0] => SELECT COUNT(`Data_riepilogo`.`key`) AS `Data_riepilogo.count` FROM `le7yz_cf_capo` AS `Data_riepilogo` WHERE `Data_riepilogo`.`capo` LIKE '%oopiop_22/6/2017%';
                    [1] => SELECT `Data_riepilogo`.`cognome` AS `Data_riepilogo.cognome`, `Data_riepilogo`.`nome` AS `Data_riepilogo.nome`, `Data_riepilogo`.`data_nascita` AS `Data_riepilogo.data_nascita`, `Data_riepilogo`.`cittadinanza` AS `Data_riepilogo.cittadinanza`, `Data_riepilogo`.`comune` AS `Data_riepilogo.comune` FROM `le7yz_cf_capo` AS `Data_riepilogo` WHERE `Data_riepilogo`.`capo` LIKE '%oopiop_22/6/2017%' LIMIT 30;
                )

            [var] => Array
                (
                    [0] => Array
                        (
                            [Data_riepilogo] => Array
                                (
                                    [cognome] => oopiop
                                    [nome] => opioipo
                                    [data_nascita] => 12/12/2012
                                    [cittadinanza] => ITALIA
                                    [comune] => ABBADIA ALPINA      
                                )

                        )

                    [1] => Array
                        (
                            [Data_riepilogo] => Array
                                (
                                    [cognome] => ospi
                                    [nome] => iuio
                                    [data_nascita] => 12/12/2012
                                    [cittadinanza] => KUWAIT
                                    [comune] => AFGHANISTAN         
                                )

                        )

                )

        )

)


in the section I use this:

 <?php

echo $this->data("Data_riepilogo.cognome", "default value");
    ?>


But it prints default value....
vismay 23 Jun, 2017
After some investigation, I could obtain a value with this code:

{var:read_data69.Data_riepilogo.cognome}


And I obtain an array with:
{var:read_data69.Data_riepilogo}



But How can I mix up with this code:

<?php
echo '<table cellspacing="2" cellpadding="2"><tr><th>Nome</th><th>Data di nascita</th><th>Cittadinanza</th><th>Luogo di nascita</th><th>Bottone</th></tr>';
foreach ($form->data['Data_riepilogo'] as $d ) {
echo "<tr><td>{$d['cognome']}{$d['nome']}</td><td>{$d['data_nascita']}</td><td>{$d['cittadinanza']}</td><td>{$d['comune']}</td><td>Bottone</td></tr>";
}
echo '</table>';
?>
Max_admin 23 Jun, 2017
Hi vismay,

You need to use a Loop action, in the data provider use {var:read_data69} and in the content use this:

<tr><td>
{var:loop_name.row.Data_riepilogo.nome}
</td></tr>

That s just a sample code, you need to build the loop content code according to your needs.

Best regards,
Max
Max, ChronoForms developer
ChronoMyAdmin: Database administration within Joomla, no phpMyAdmin needed.
ChronoMails simplifies Joomla email: newsletters, logging, and custom templates.
vismay 23 Jun, 2017
Quite amazing, but still full of mystery this new CF6!

is there a manual where I can find this functions? Because is very different from CF5!
Max_admin 23 Jun, 2017
Hi vismay,

I'm currently trying to complete a manual on most features, please give me few days.

Best regards,
Max
Max, ChronoForms developer
ChronoMyAdmin: Database administration within Joomla, no phpMyAdmin needed.
ChronoMails simplifies Joomla email: newsletters, logging, and custom templates.
vismay 25 Jun, 2017
Finally I've decided for an old style solution:

  <h4>Verifica inserimento</h4>
            <?php
$capo = $this->data("cognome", "default value") . "_" . $this->data("data_arrivo", "default value");

echo '<b>Capogruppo o capofamiglia</b><br><table cellspacing="2" cellpadding="2"><tr><th width="30%">Nome</th><th width="20%">Data di nascita</th><th width="20%">Cittadinanza</th><th width="20%">Luogo di nascita</th><th width="10%">Cancella</th></tr>';

$db =& JFactory::getDBO();
$query = "
SELECT *
FROM `le7yz_cf_capo` 
WHERE `capo`  = '$capo'
AND `tipo_cod` REGEXP '16|17|18';
";
$db->setQuery($query);
$data = $db->loadAssocList();
foreach ( $data as $d ) {
echo '<tr><td>'.$d['cognome'].' '.$d['nome'].'</td><td>'.$d['data_nascita'].'</td><td>'.$d['cittadinanza'].'</td><td>'.$d['comune'].'</td><td>Cancella</td></tr>';
    }
    echo '</table>';


$db =& JFactory::getDBO();
$query = "
SELECT *
FROM `le7yz_cf_capo` 
WHERE `capo`  = '$capo'
AND `tipo_cod` NOT REGEXP '16|17|18';
";
$db->setQuery($query);
$data = $db->loadAssocList();
echo '<br><b>ospiti aggiuntivi</b><br><table cellspacing="2" cellpadding="2"><tr><th width="30%">Nome</th><th width="20%">Data di nascita</th><th width="20%">Cittadinanza</th><th width="20%">Luogo di nascita</th><th width="10%">Cancella</th></tr>';
foreach ( $data as $d ) {

 echo '<tr><td>'.$d['cognome'].' '.$d['nome'].'</td><td>'.$d['data_nascita'].'</td><td>'.$d['cittadinanza'].'</td><td>'.$d['comune'].'</td><td>cancella</td></tr>';
    }
    echo '</table>';

?>


that reproduce the following table:



Now I'm struggling to find a solution ho to put in "Cancella" a link that cancel the specific database row.

I was thinking about calling an event and reload.
It's probably javascript a better solution?
Max_admin 25 Jun, 2017
Hi vismay,

You mean to delete the row ? for this you are using Chronoforms ? if yes then you should be using ChronoConnectivity instead.

You could link to a new event "delete" and execute a delete data function.

Best regards,
Max
Max, ChronoForms developer
ChronoMyAdmin: Database administration within Joomla, no phpMyAdmin needed.
ChronoMails simplifies Joomla email: newsletters, logging, and custom templates.
vismay 25 Jun, 2017
Of course I was thinking about ChronoConnectivity, but this process is still inside a form not after submit...
Is there a possibility to switch between CF and CC?
Max_admin 27 Jun, 2017
Hi vismay,

You will need to create the data listing and management part in Connectivity, please check the FAQs > Connectivity 6 section for a tutorial.

You can then display your list using a plugin and display the form using a plugin too on the same page.

Best regards,
Max
Max, ChronoForms developer
ChronoMyAdmin: Database administration within Joomla, no phpMyAdmin needed.
ChronoMails simplifies Joomla email: newsletters, logging, and custom templates.
vismay 27 Jun, 2017
...and they exchange the variables and datas? Two way exchange?
Max_admin 28 Jun, 2017
Hi vismay,

No, they will be 2 different entities.

But you can have a read data function in Connectivity and another one in the forms.

You can also call your form "section" inside Connectivity "form" view:
{chronoform.section:form_name/section_name}

Best regards,
Max
Max, ChronoForms developer
ChronoMyAdmin: Database administration within Joomla, no phpMyAdmin needed.
ChronoMails simplifies Joomla email: newsletters, logging, and custom templates.
vismay 28 Jun, 2017
Ah, ok... so basically I can use portions of Chronoform inside Connectivity?

But then the only common parameter in database should be a session id to call back what in the form is submitted?
vismay 28 Jun, 2017
Another question:

in calendar field in chronoform 6 I use {date:Y-m-d} in earliest date to start calendar from today. Works perfectly.
In ChronoConnectivity 6 this option doesn't work.

Also if in CC6 I show the section of CF 6 in which the working calendar is, same problem.

Thanks for help.
This topic is locked and no more replies can be posted.