display / format DB content

ledev 23 Nov, 2015
Hi,

I have inserted data into my database using ChronoForm V5. Now i want to display the data.
In the tab Models i have created a model name / i have indicated the DB table name and in condition i have entered
<?php return array('my_model_name.my_field' => '17'); ?> (because i want the raw where mu_field = 17 ...)
In fiels / order i have indicated what fiels i need from the table

In the Front list tab, if I choose TABLE and in column list i write
my_model.my_field1:my_field1
...
my_model.my_fieldn:my_fieldn
the result is the display of the data but not arrange like i need

To try to modify the display, in display type i have selected Custom
then in List display,
- in header box i have entered HTML code to diplay the header tab
- in footer box i have entered HTML code to diplay the footer tab
My concern is what to enter into the body box in the middle of the HTML code to display the values extracted from the database ???

I have tested
- <?php echo my_model.myfield; ?>
- <?php echo {my_field}; ?>
- <?php echo $row[my_model][my_field] ?>
- <?php echo $form->data['my_field'] ?>
And nothing is diplaying results, I'm totally lost
GreyHead 24 Nov, 2015
Hi ledev,

You need to add the HTML to create a table row like this
<tr>
  <td style='width: 50px;' >{content.title}</td>
  <td>{content.image}</td>
  <td>{content.input}</td>
</tr>
- this is from a test listing of mine, you will have different values.

Bob
ledev 24 Nov, 2015
Hi
thanks for the answer. Not sure what you mean by {content.title} / {content.image} / {content.input}
What are "content" / "title" for you ?
I have tested with {my_model.myfield} with my_model = name of the model in the model tab / myfield = name of the field in the database.
I have tested {my_model.myfield} in HTML and <?php echo {my_model.myfield}; ?> and nothing OK...
Any idea
GreyHead 24 Nov, 2015
Hi ledev,

It would be {model_id.column_name}

Bob
ledev 03 Dec, 2015
Hi Again Bob,

The last message allow me to display the needed data, cool, but ...

the data on the DB as store like that (I have verified with PHPMyAdmin):
test1
line1_text
line2_text

test2
line3_text
line4 text


And it displayed like that wothout keeping the database text formating...
test1 line1_text line2_text test2 line3_text line4 text

I have tried to display it in HTML
<br /><br />
{test_1_db_access_bru.Texte_complet}
<br /><br />


or in PHP, tried to format it with str_replace and nl2br and still same result, test is displayed with formating
<?php
$toto = '{test_1_db_access_bru.Texte_complet}';
//$text=str_replace("\n", "<br>", '{test_1_db_access_bru.Texte_complet}');
//$text=nl2br($toto);
$text=str_replace('\n', '<br />', '{test_1_db_access_bru.Texte_complet}');
echo $text;
?>

and last but not least, just to bore me, if I test that code, the display is fine
<textarea>".'{test_1_db_access_bru.Texte_complet}'."</textarea>
ledev 03 Dec, 2015
Hi Again Bob same text but formated,


The last message allow me to display the needed data, cool, but ... the data on the DB as store like that (I have verified with PHPMyAdmin):

test1

line1_text

line2_text


test2

line3_text

line4 text



And it displayed like that wothout keeping the database text formating...

test1 line1_text line2_text test2 line3_text line4 text



I have tried to display it in HTML

<br /><br />

{test_1_db_access_bru.Texte_complet}

<br /><br />



Or in PHP, tried to format it with str_replace and nl2br and still same result, test is displayed with formating

<?php

$toto = '{test_1_db_access_bru.Texte_complet}';

//$text=str_replace("\n", "<br>", '{test_1_db_access_bru.Texte_complet}');

//$text=nl2br($toto);

$text=str_replace('\n', '<br />', '{test_1_db_access_bru.Texte_complet}');

echo $text;

?>




And last but not list, just to bore me, if I test that code, the display is fine

<textarea>".'{test_1_db_access_bru.Texte_complet}'."</textarea>
GreyHead 03 Dec, 2015
Hi ledev,

You can't use the {model_id.name} syntax in PHP :-( Please try this:
<?php
$text=str_replace("\n", '<br />', $form->data['test_1_db_access_bru']['Texte_complet']);
echo $text;
?>

Bob
ledev 03 Dec, 2015
Hi,

The proposed code don't display anything ...

🤨
GreyHead 03 Dec, 2015
Hi ledev,

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
This topic is locked and no more replies can be posted.