Forums

Ho can i display data from 2n Table

Fredolino 16 Mar, 2016
Hi,

I wanted to ask how I can display the data from a sub-table under View action.
The data in the main table so I can show in CC5:
<td> {Firma.name} </ td>

But if I want the members of the main table data stored in a second table indicate?
Modelname 2. table: Firma_1
As I have multiplier for the Designer (CF5) for the input fields: __N__
<td> {Firma.Firma_1.partner}</td> not working.

Thank you in advance for the help.

F.
GreyHead 16 Mar, 2016
Hi Fredolino,

How do you want to show them?

ChronoForms only has one row for each record so you could setup a join to show one row for each record in the sub-table - and therefore several rows for each record in the main table.

Or you could possible use a Custom HTML entry to show a mini-table in each row. That might work if there are only a few sub-records.

Or you could add a link to each row to show the sub-records in a Modal window.

Bob
Fredolino 16 Mar, 2016
Hi Bob,

thanx for this information. :-)
Ok, i use a custom HTML entry to show a mini-table in each row.
Where can I find examples of how I can do that in my case?

F.
Fredolino 16 Mar, 2016
Hi,
i have this script, but is not ok.
     
<table>
<?php
foreach ($form->data['Firma_1'] as $d) {
  echo "<tr>
    <td>{$d['berufsfeld']}</td>
    <td>{$d['position']}</td>
    <td>{$d['spezifikation']}</td>
     ...
  </tr>";
}
?>
</table>
  
GreyHead 17 Mar, 2016
Hi Fredolino,

I've never seen that done before so can't point you to an example.

In CCv5 the row data is in $row, (not in $form->data).

Bob
Fredolino 17 Mar, 2016
Hi Bob,

it's a sub-table with multiple columns.
This sub-table is to be displayed in a cell of the main table in CC5.
I know otherwise not how that is different.
I once attached a screen by the debugger.

The data from the model "Firma" are displayed correctly. It's about the data model "Firma 1".

Thank you for your help.
F.
GreyHead 17 Mar, 2016
Hi Fredolino,

Have you tried using $row in your code?

Bob
Fredolino 17 Mar, 2016
I think that I do not find the solution currently. 🙄
<table>
<?php
foreach ($row['Firma_1'] as $d) {
echo "<tr>
<td>{$d['berufsfeld']}</td>
<td>{$d['position']}</td>
<td>{$d['spezifikation']}</td>
</tr>";
}
?>
</table>
GreyHead 17 Mar, 2016
Hi fredolino.

Please add echo $row; in there temporarily so that you can see what data is in $row, that may help.

Bob
Fredolino 17 Mar, 2016
I do it still wrong ...


<table>
<?php
foreach ($form->data['Firma_1'] as $d) {
echo "<tr>";
echo "<td>"$row->{$d['berufsfeld']}"</td>";
echo "<td>"$row->{$d['position']}"</td>";
echo "<td>"$row->{$d['spezifikation']}"</td>";
"</tr>";
}
?>
</table>
Max_admin 19 Mar, 2016
Where do you have this code ? please try this to find the $row contents:

<?php pr($row); ?>
Max, ChronoForms developer
ChronoMyAdmin: Database administration within Joomla, no phpMyAdmin needed.
ChronoMails simplifies Joomla email: newsletters, logging, and custom templates.
GreyHead 19 Mar, 2016
Hi Fredolino,

You do still do it wrong - please check your PHP carefully this is not valid PHP
echo "<td>"$row->{$d['berufsfeld']}"</td>";
Try this instead
echo "<td>{$row->$d['berufsfeld']}</td>";

Bob
Fredolino 21 Mar, 2016
Hi,

I get it. Thank you very much.
lightbulb

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