This is not an elegant way, but you can do it using cfdb-html:
– Put you own TABLE, THEAD, TR, TH tags in your post, followed by TBODY
– followed by a cfdb-html short code that output TR, TD element for each row
– After the short code, put in closign /TBODY /TABLE tags
You choose the names you want in our TH tags
Thread Starter
Panos
(@panosk)
First of all thank you for the advise. I tried this but the Header Text is displayed in every row.
Here is my code. (Short)
<table border="1">
<thead>
<tr>
<th>Name</th>
<th>Surname</th>
</tr>
</thead>
<tbody>
<tr>
<td>${text-708}</td>
<td>${your-name}</td>
</tr>
</tbody>
</table>
Probably it is my mistake but I can not figure it out.
Put that stuff outside the shortcode
<table border="1">
<thead>
<tr>
<th>Name</th>
<th>Surname</th>
</tr>
</thead>
<tbody>
[cfdb-html form="your-form"]
<tr>
<td>${text-708}</td>
<td>${your-name}</td>
</tr>
[/cfdb-html]
</tbody>
</table>
Thread Starter
Panos
(@panosk)
Thank you for the solution. It worked great.
Thread Starter
Panos
(@panosk)
Would it be possible to calculate the summary of a specific collumn? I have for example a collumn that displays a choise from a dropdown menu. I know it is a text but the first character is arithmetic.
If you want to compute a sum, then you need to do this as a create your own short code instead of using cfdb-html. Here is some code to get you started. Change ‘some-column’ to match your column name.
require_once(ABSPATH . 'wp-content/plugins/contact-form-7-to-database-extension/CFDBFormIterator.php');
$exp = new CFDBFormIterator();
$exp->export($atts['form'], $atts);
echo '<table border="1">
<thead>
<tr>
<th>Name</th>
<th>Surname</th>
</tr>
</thead>
<tbody>';
$summary = 0;
while ($row = $exp->nextRow()) {
echo '<tr>';
echo '<td>'. $row['text-708'] . '</td>';
echo '<td>'. $row['your-name'] . '</td>';
echo '</tr>';
// first character of string is number
$summary = $summary + substr($row['some-column'], 0, 1);
}
echo '</tbody></table>';
echo "$summary";
Thread Starter
Panos
(@panosk)
Thanks a lot. It was very helpful. Finally I managed to have a sum of the columns.
However I want to improve it by add the summary of the column in the last entry of the specific row.
Is this possible?
Thread Starter
Panos
(@panosk)
Hello. Is it possible to create for example 3 different tables instead of one that are assigned each to a choice of a radio button? Lets say place of delivery.
I tried to put it after while a constraint but didn’t worked.
Any ideas
I suppose so. The template code for “create your own short code” basically shows you how to get and loop through the data. You can write your own PHP code there to create different tables or anything you want based on the data you see. It’s up to you to write the code.