|
Smarty
WARNING: All discussion is moving to https://reddit.com/r/smarty, please go there! This forum will be closing soon. |
|
View previous topic :: View next topic |
Author |
Message |
AlbertoALH Smarty n00b
Joined: 11 Sep 2016 Posts: 1
|
Posted: Sun Sep 11, 2016 4:14 am Post subject: Help to Convert PHP to Smarty |
|
|
Hi, i using smarty, how to convert this part of code PHP to smarty engine...
HOW TO FOREACH IN SMARTY??????
TANK'S!!
Quote: | <table class="tbl-qa">
<thead>
<tr>
<th class="table-header" width="10%">Q.No.</th>
<th class="table-header">Question</th>
<th class="table-header">Answer</th>
</tr>
</thead>
<tbody>
<?php
foreach($faq as $k=>$v) {
$pergunta = $faq[$k]["pergunta"];
$resposta = $faq[$k]["resposta"];
?>
<tr class="table-row">
<td><?php echo $k+1; ?></td>
<td contenteditable="true" onBlur="saveToDatabase(this,'pergunta','<?php echo $faq[$k]["id"]; ?>')" onClick="showEdit(this);"><?php echo $pergunta; ?></td>
<td contenteditable="true" onBlur="saveToDatabase(this,'resposta','<?php echo $faq[$k]["id"]; ?>')" onClick="showEdit(this);"><?php echo $resposta; ?></td>
</tr>
<?php
}
?>
</tbody>
</table>
|
|
|
Back to top |
|
elpmis Smarty Elite
Joined: 07 Jun 2007 Posts: 321
|
|
Back to top |
|
AnrDaemon Administrator
Joined: 03 Dec 2012 Posts: 1785
|
Posted: Sun Sep 11, 2016 8:51 pm Post subject: |
|
|
First you should stop using foreach() like that, though.
And before that, stop yelling at people for no reason.
Code: | {foreach $faq as $v}<tr class="table-row">
<td>{$v@key+1}</td>
<td contenteditable="true" onBlur="saveToDatabase(this,'pergunta','{$v.id}')" onClick="showEdit(this);">{$v.pergunta}</td>
<td contenteditable="true" onBlur="saveToDatabase(this,'resposta','{$v.id}')" onClick="showEdit(this);">{$v.resposta}</td>
</tr>{/foreach} |
|
|
Back to top |
|
|
|
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum
|
Powered by phpBB © 2001, 2005 phpBB Group
|