Php 如何使用smarty正确显示阵列中的数据?
当我的顾问只返回一行时,没关系。。。 但当返回多行时,我的表崩溃 输出(第二个图像和错误)Php 如何使用smarty正确显示阵列中的数据?,php,html,css,smarty,Php,Html,Css,Smarty,当我的顾问只返回一行时,没关系。。。 但当返回多行时,我的表崩溃 输出(第二个图像和错误) 在嵌套的foreach中,您将使用item=“estoque”两次 对于线路: {foreach from=$datas item="estoque"} 您需要为item使用不同的名称,以避免循环覆盖彼此的值。在嵌套的foreach中,您将使用item=“estoque”两次 对于线路: {foreach from=$datas item="estoque"} 您需要为项使用不同的名称,以避免循环
在嵌套的
foreach
中,您将使用item=“estoque”
两次
对于线路:
{foreach from=$datas item="estoque"}
您需要为
item
使用不同的名称,以避免循环覆盖彼此的值。在嵌套的foreach
中,您将使用item=“estoque”
两次
对于线路:
{foreach from=$datas item="estoque"}
您需要为
项使用不同的名称
,以避免循环覆盖彼此的值。查看这是否适用于您的项目。您是否遇到smarty错误或任何其他错误
<table class="table-filtro">
<thead>
<tr>
<th class="nome-quarto">TIpo</th>
<th>N° Quarto</th>
<th>Label</th>
{foreach from=$numeros item="estoque_1"}
<th class="th-periodo" title='{$estoque.reserva_checkin|date_format:"%e th %B %Y"}'>{$estoque_1.reserva_checkin|date_format:"%e"}</th>
<!--<th class="th-periodo">{$estoque.reserva_checkin|date_format:"%e de %B de %Y"}</th>-->
{/foreach}
</tr>
</thead>
<tbody>
{foreach from=$listar item="estoque_2"}
<tr>
<td class="nome-quarto">{$estoque.tipo_nome}</td>
<td>{if $estoque_2.quarto_numero|count_characters eq '1'}0{$estoque_2.quarto_numero}{else}{$estoque_2.quarto_numero}{/if}</td>
<td>{$estoque.quarto_descricao}</td>
{foreach from=$datas item="estoque_3"}
<td><img title="{if $estoque_3.quarto_numero|count_characters eq '1'}0{$estoque_3.quarto_numero}{else}{$estoque_3.quarto_numero}{/if} -- {$estoque_3.reserva_checkin|date_format:"%e de %B de %Y"}" src="http://{$smarty.server.SERVER_NAME}/reservas/images/cubos/{if $estoque_3.reserva_status eq '3'}vermelho{elseif $estoque_3.reserva_status eq '2'}amarelo{else}verde{/if}.jpg" /></td>
{/foreach}
</tr>
{/foreach}
</tbody>
</table>
蒂波
四分之一
标签
{foreach from=$numeros item=“estoque_1”}
{$estoque_1.保留签入|日期_格式:“%e”}
{/foreach}
{foreach from=$listar item=“estoque_2”}
{$estoque.tipo_nome}
{if$estoque_2.quarto_numero | count_characters eq'1'}0{$estoque_2.quarto_numero}{else}{$estoque_2.quarto_numero}{/if}
{$estoque.quarto_descripcao}
{foreach from=$datas item=“estoque_3”}
{/foreach}
{/foreach}
查看这是否适用于您的系统,以及您是否遇到smarty错误或任何其他错误
<table class="table-filtro">
<thead>
<tr>
<th class="nome-quarto">TIpo</th>
<th>N° Quarto</th>
<th>Label</th>
{foreach from=$numeros item="estoque_1"}
<th class="th-periodo" title='{$estoque.reserva_checkin|date_format:"%e th %B %Y"}'>{$estoque_1.reserva_checkin|date_format:"%e"}</th>
<!--<th class="th-periodo">{$estoque.reserva_checkin|date_format:"%e de %B de %Y"}</th>-->
{/foreach}
</tr>
</thead>
<tbody>
{foreach from=$listar item="estoque_2"}
<tr>
<td class="nome-quarto">{$estoque.tipo_nome}</td>
<td>{if $estoque_2.quarto_numero|count_characters eq '1'}0{$estoque_2.quarto_numero}{else}{$estoque_2.quarto_numero}{/if}</td>
<td>{$estoque.quarto_descricao}</td>
{foreach from=$datas item="estoque_3"}
<td><img title="{if $estoque_3.quarto_numero|count_characters eq '1'}0{$estoque_3.quarto_numero}{else}{$estoque_3.quarto_numero}{/if} -- {$estoque_3.reserva_checkin|date_format:"%e de %B de %Y"}" src="http://{$smarty.server.SERVER_NAME}/reservas/images/cubos/{if $estoque_3.reserva_status eq '3'}vermelho{elseif $estoque_3.reserva_status eq '2'}amarelo{else}verde{/if}.jpg" /></td>
{/foreach}
</tr>
{/foreach}
</tbody>
</table>
蒂波
四分之一
标签
{foreach from=$numeros item=“estoque_1”}
{$estoque_1.保留签入|日期_格式:“%e”}
{/foreach}
{foreach from=$listar item=“estoque_2”}
{$estoque.tipo_nome}
{if$estoque_2.quarto_numero | count_characters eq'1'}0{$estoque_2.quarto_numero}{else}{$estoque_2.quarto_numero}{/if}
{$estoque.quarto_descripcao}
{foreach from=$datas item=“estoque_3”}
{/foreach}
{/foreach}
仍在中断…黄色方块对应于第三行(而不是第三列)…但我得到了相同的结果,(如图)仍在中断…黄色方块对应于第三行(而不是第三列)…但我得到了相同的结果,(如图)您能发布表格的输出HTML以及模板HTML吗?可能更容易弄清楚发生了什么。您可以发布表的输出HTML以及模板HTML吗?可能更容易弄清楚到底发生了什么。
{foreach from=$datas item="estoque"}
<table class="table-filtro">
<thead>
<tr>
<th class="nome-quarto">TIpo</th>
<th>N° Quarto</th>
<th>Label</th>
{foreach from=$numeros item="estoque_1"}
<th class="th-periodo" title='{$estoque.reserva_checkin|date_format:"%e th %B %Y"}'>{$estoque_1.reserva_checkin|date_format:"%e"}</th>
<!--<th class="th-periodo">{$estoque.reserva_checkin|date_format:"%e de %B de %Y"}</th>-->
{/foreach}
</tr>
</thead>
<tbody>
{foreach from=$listar item="estoque_2"}
<tr>
<td class="nome-quarto">{$estoque.tipo_nome}</td>
<td>{if $estoque_2.quarto_numero|count_characters eq '1'}0{$estoque_2.quarto_numero}{else}{$estoque_2.quarto_numero}{/if}</td>
<td>{$estoque.quarto_descricao}</td>
{foreach from=$datas item="estoque_3"}
<td><img title="{if $estoque_3.quarto_numero|count_characters eq '1'}0{$estoque_3.quarto_numero}{else}{$estoque_3.quarto_numero}{/if} -- {$estoque_3.reserva_checkin|date_format:"%e de %B de %Y"}" src="http://{$smarty.server.SERVER_NAME}/reservas/images/cubos/{if $estoque_3.reserva_status eq '3'}vermelho{elseif $estoque_3.reserva_status eq '2'}amarelo{else}verde{/if}.jpg" /></td>
{/foreach}
</tr>
{/foreach}
</tbody>
</table>