2014-12-15 6 views
0

죄송합니다. 내 지식이 적기 때문에 질문하는 법을 모르겠습니다.PHP Smarty 값이있는 변수

메시지 : no records found 당신이 부서 "7"에 더 티켓이없는 경우

{if $ticket.did["7"] == ''} 
    No records found! 
{/if} 

내 Whmcs의 TPL 코드 :

내가 할 노력하고있어의 예를주지
{foreach from=$tickets item=ticket} 
    {if $ticket.did == '7'} 
    <tr> 
     <td>#{$ticket.tid}</td> 
     <td>{$ticket.title}</td> 
     <td>{$ticket.status}</td> 
     <td><a href="viewticket.php?tid={$ticket.tid}&c={$ticket.c}">View</a></td> 
    </tr> 
    {/if} 
{/foreach} 
    {if $ticket.did["7"] == ''} 
    <tr> 
     <td colspan="6" class="textcenter">{$LANG.norecordsfound}</td> 
    </tr> 
    {/if} 

감사!

+0

직면 한 오류는 무엇입니까? –

+0

for 루프 뒤에 $ ticket.did 값을 echo합니다. 데이터를 가져 왔는지 확인하십시오. – unixmiah

+0

@Vitor lima : 메시지와 티켓 목록은 if else가 작동하지 않습니다. –

답변

2

새 변수를 초기화하고 루프의 조건이 충족 될 때 true로 설정할 수 있습니다.

{foreach from=$tickets item=ticket} 
    {if $ticket.did == '7'} 
    {assign var="ticketFound" value="true"} 
    <tr> 
     <td>#{$ticket.tid}</td> 
     <td>{$ticket.title}</td> 
     <td>{$ticket.status}</td> 
     <td><a href="viewticket.php?tid={$ticket.tid}&c={$ticket.c}">View</a></td> 
    </tr> 
    {/if} 
{/foreach} 
    {if !$ticketFound} 
    <tr> 
     <td colspan="6" class="textcenter">{$LANG.norecordsfound}</td> 
    </tr> 
    {/if} 
+0

안녕하세요! WORKS FINE .... hehehe 대단히 감사합니다! –