Buy Now
Sign in

A href TCPDF

Yudhizth , April 03 2018, 07:45
Y
Yudhizth 140
April 03 2018, 07:45 #376647
Dear all,
I have a problem when creating table layout within TCPDF. The a href link on the result is not clickable, I'm using this code to generate the table
<table border="1" cellpadding="3">
<thead>
<tr>
<th bgcolor="#a3d0f7">BERKAS</th>
<th bgcolor="#a3d0f7">URL</th>
</tr>
</thead>
<tbody>
<?php
foreach ( $form->data['syarat'] as $p ) {
echo "<tr>

<td>{$p['nama_file']}</td>
<td><a href={$p['url_berkas']}>Download</a></td>

</tr>";
}
?>
</tbody>
</table>
However, when I try to use custom code, It works well.
Thank you
GreyHead 64
April 03 2018, 10:15 #376653
Hi Yudhizth ,
Please try adding quotes round the URL. <td><a href="{$p['url_berkas']}" >Download</a></td>
Bob
ChronoForms technical support
If you'd like to buy me a coffee or two, thank you very much
Y
Yudhizth 140
April 03 2018, 10:32 #376656
Thank you Bob,
I try to add quotes, but it becomes a blank pdf.
This is the debugger result without TcPDF action
Array
(
[option] => com_chronoforms5
[chronoform] => Table-PDF
[event] => submit
[button1] => Submit
[syarat] => Array
(
[0] => Array
(
[id_berkas] => 1
[uniq_id] => 0833ab9790e48949c01e2bac6fbb650e845b12d0
[user_id] => 0
[created] => 2016-03-31 07:52:10
[modified] =>
[url_berkas] => http://localhost/jom/components/com_chronoforms5/chronoforms/uploads/save-dibelakang/20160331075210_pdf-sample.pdf
[status] => 0
[id_permohonan] =>
[nama_file] =>
)

[1] => Array
(
[id_berkas] => 2
[uniq_id] => e1b271371b7d7e39c5b6ff73965afbf1e89be55c
[user_id] => 0
[created] => 2017-08-11 07:46:23
[modified] =>
[url_berkas] => http://localhost/jom/components/com_chronoforms5/chronoforms/uploads/demo-fields-multiplier-des/20170811074623_file1.pdf
[status] =>
[id_permohonan] =>
[nama_file] => yudhi
)

[2] => Array
(
[id_berkas] => 3
[uniq_id] => 6990f14b15eb8f24d39cd94fc3565a241da081c9
[user_id] => 0
[created] => 2017-08-11 07:46:23
[modified] =>
[url_berkas] => http://localhost/jom/components/com_chronoforms5/chronoforms/uploads/demo-fields-multiplier-des/20170811074623_file2.pdf
[status] =>
[id_permohonan] =>
[nama_file] => setiawan
)

[3] => Array
(
[id_berkas] => 4
[uniq_id] => 320f5e601a55a5977fc1f6ffd850b3c17d8d1cb1
[user_id] => 0
[created] => 2017-08-11 07:48:10
[modified] =>
[url_berkas] => http://localhost/jom/components/com_chronoforms5/chronoforms/uploads/demo-fields-multiplier-des/20170811074810_file1.pdf
[status] =>
[id_permohonan] =>
[nama_file] => Salinan Izin Penyelenggaraan ke 0
)

[4] => Array
(
[id_berkas] => 5
[uniq_id] => cdcdef28e02fdaf2280a2037560f2db249b75ddb
[user_id] => 0
[created] => 2017-08-11 07:48:10
[modified] =>
[url_berkas] => http://localhost/jom/components/com_chronoforms5/chronoforms/uploads/demo-fields-multiplier-des/20170811074810_file2.pdf
[status] =>
[id_permohonan] =>
[nama_file] => Salinan Izin Penyelenggaraan ke 2
)

[5] => Array
(
[id_berkas] => 6
[uniq_id] => 6f3508c1237d2d150ac3fcb60e0da5a3522e5def
[user_id] => 0
[created] => 2017-08-11 07:48:10
[modified] =>
[url_berkas] => http://localhost/jom/components/com_chronoforms5/chronoforms/uploads/demo-fields-multiplier-des/20170811074810_file3.pdf
[status] =>
[id_permohonan] =>
[nama_file] => Salinan Izin Penyelenggaraan ke 3
)

[6] => Array
(
[id_berkas] => 7
[uniq_id] => e5c61a104e8e8eb90c9ec29233a12d5502e6c5db
[user_id] => 0
[created] => 2017-08-11 07:54:06
[modified] =>
[url_berkas] => http://localhost/jom/components/com_chronoforms5/chronoforms/uploads/demo-fields-multiplier-des/20170811075406_file1.pdf
[status] =>
[id_permohonan] =>
[nama_file] => Salinan Izin Penyelenggaraan ke 1
)

[7] => Array
(
[id_berkas] => 8
[uniq_id] => 4f38e19d8e8b6c4353eff412909ed82fe50c863d
[user_id] => 0
[created] => 2017-08-11 07:54:06
[modified] =>
[url_berkas] => http://localhost/jom/components/com_chronoforms5/chronoforms/uploads/demo-fields-multiplier-des/20170811075406_file2.pdf
[status] =>
[id_permohonan] =>
[nama_file] => Salinan Izin Penyelenggaraan ke 2
)

[8] => Array
(
[id_berkas] => 9
[uniq_id] => faba16b9c7a28682f5308740a2f2ae43ba6f3ae9
[user_id] => 0
[created] => 2017-08-11 07:54:06
[modified] =>
[url_berkas] => http://localhost/jom/components/com_chronoforms5/chronoforms/uploads/demo-fields-multiplier-des/20170811075406_file3.pdf
[status] =>
[id_permohonan] =>
[nama_file] => Salinan Izin Penyelenggaraan ke 3
)

[9] => Array
(
[id_berkas] => 10
[uniq_id] => 8cc22579bdd43ded98d12caf98f38d275a62360f
[user_id] => 0
[created] => 2017-11-20 05:36:11
[modified] =>
[url_berkas] => http://localhost/jom/components/com_chronoforms5/chronoforms/uploads/Fileupload-bugs/20171120053611_file1.pdf
[status] =>
[id_permohonan] =>
[nama_file] => Wakwaw
)

[10] => Array
(
[id_berkas] => 11
[uniq_id] => 659fd91a176695691fc2b459a20e2bad508be001
[user_id] => 0
[created] => 2017-11-20 05:36:36
[modified] =>
[url_berkas] => http://localhost/jom/components/com_chronoforms5/chronoforms/uploads/Fileupload-bugs/20171120053636_file3.pdf
[status] =>
[id_permohonan] =>
[nama_file] => Wakwaw
)

[11] => Array
(
[id_berkas] => 12
[uniq_id] => 8569897348f7057b04a842c7f51eff16c2121bb5
[user_id] => 0
[created] => 2017-11-20 05:42:30
[modified] =>
[url_berkas] => http://localhost/jom/components/com_chronoforms5/chronoforms/uploads/Fileupload-bugs/20171120054230_file19.pdf
[status] =>
[id_permohonan] =>
[nama_file] => Wakwaw
)

[12] => Array
(
[id_berkas] => 13
[uniq_id] => 06c8333d01258c2440ef939f1862e1639f836ea8
[user_id] => 0
[created] => 2018-03-01 04:53:43
[modified] =>
[url_berkas] => http://localhost/jom/components/com_chronoforms5/chronoforms/uploads/demo-fields-multiplier-des/20180301045343_file3.pdf
[status] =>
[id_permohonan] =>
[nama_file] => Salinan Izin Penyelenggaraan ke 1
)

[13] => Array
(
[id_berkas] => 14
[uniq_id] => 3ec237ffc3bab7fe7b329668d26987cc0cf878aa
[user_id] => 0
[created] => 2018-03-01 04:53:43
[modified] =>
[url_berkas] => http://localhost/jom/components/com_chronoforms5/chronoforms/uploads/demo-fields-multiplier-des/20180301045343_file6.pdf
[status] =>
[id_permohonan] =>
[nama_file] => Salinan Izin Penyelenggaraan ke 2
)

)

)
Attachments
Table-PDF_20180403172741.pdf
(7.24 KiB)
201 Downloads/Views
GreyHead 64
April 03 2018, 17:50 #376670
Hi Yudhizth,
I'm not sure that PHP works well inside the TCPDF template - please try building the table in a Custom Code action before the TCPDF action, save it to the $form->data array as say $form->data['file_table'] then add that new element in the TCPDF template.
Bob
ChronoForms technical support
If you'd like to buy me a coffee or two, thank you very much
Y
Yudhizth 140
April 04 2018, 03:35 #376682
 1
Thanks Bob,
Finally I found the solution, just like your advice. Here is the code
<?php
$db = JFactory::getDbo();
//$id = JRequest::getString('id', '', 'post');

// Create a new query object.
$query = $db->getQuery(true);

$query = "SELECT * FROM xsd7p_t_berkas";

// Reset the query using our newly populated query object.
$db->setQuery($query);
$db->query();
$jumlah = $db->getNumRows();
$results = $db->loadObjectList();

if ($jumlah < 1) {

echo "Data tidak ditemukan";

}else{


$table = '';
$table .= '<table border="1" cellpadding="3">';
$table .= '<tr>';
$table .= '<td bgcolor="#a3d0f7">BERKAS</td>';
$table .= '<td bgcolor="#a3d0f7">URL BERKAS</td>';
$table .= '</tr>';


foreach ($results as $row) {

$table .= '<tr>';
$table .= '<td>'.$row->nama_file.'</td>';
$table .= '<td><a href="'.$row->url_berkas.'">Download</a></td>';
$table .= '</tr>';

}
$table .='</table>';

$form->data["code"] = $table;
}
?>
Thank you.