I tried the suggested code. However I think it doesn´t fit exactly my needs.
What i like to show in the CC form is only the date of each record:
I put to Connection view settings of the body field:
<tr>
<td width="70 px">{recordtime}</td>
</tr>
As a result i get: 2010-04-03 - 18:12:28
But i want to show only 2010-04-03
what is the coding for showing it?
I think there doesn´t need to be a "foreach", because CC already fetched the actual record from the table.
Hi navajofra,
No it doesn't exactly fit your needs but you can easily adapt it to do what you need. All the necessary code is there.
Bob
ok. I will try it. Thx GreyHead
Hallo GreyHead,
I understand the coding now. But how can I get the content of the field recordtime?
with $date='{recordtime}' it works, but I cannot explode $date. The result of the date[0] is always the content of {recordtime}. date[1] and date[2] are empty.
How can I ask for the actual content of the field recordtime using php code in Connection View Settings-Body?
Hi navajofra,
You probably don't need to explode recordtime, just take out the substring. A MySQL date-time field value is usually in the form YYYY-MM-DD HH:MM:SS but for some reason ChronoForms uses YYYY-MM-DD - HH:MM:SS
Look in the database record to see what form at your fields take.
Bob
My problem is only how to get out the date from the recordtime field of the current record if I use the body of Connection View Settings.
I assume chronoconnectivity has already stored the current record to an array as $row->recordtime or something else.
I don´t know the name of the array so that I could use it instead of {recordtime} in the Connection view settings.
I know the Connection view settings body is only a template for displaying the records.
Can I put the code into the body or where else?
Hi navajofra,
I expect that it is stored as a string - look at the database table with PHPMyAdmin or EasySQL or the ChronoForms DataViewer to check.
You can run PHP inside the CC Body box (but not MySQL queries).
Bob
Yes it is saved as a string. what shall I do?
Btw i can run MYSQL queries in the CC Body box.
But only the first record of a table gets displayed. I don´t know the reason.
Maybe it is my coding.
<?php
$database->setQuery( "SELECT * FROM #__chronoforms_profile WHERE cf_id = cf_id LIMIT 1" );
$categories = $database->loadObjectList();
foreach($categories as $category) {
$date=explode(" ",$category->recordtime);
echo '<td width="80 px">'.$date[0]."</td>";
}
?>
Hi,
I've the same problem.
Mr GreyHead, write the solution please!
Thanks...
Solution:
<?php
$date=explode(' ',$MyRow->recordtime);
echo $date[0];
?>