Print just once inside loop. Hi all! I have a small situation that I’m unable to solve. I have a result list (3 results) by day of the week (see below) So when I add 3 documents today my list print Today Xxxxxxxxxxxx Today xxxxxxxxxxxx Today xxxxxxxxxxxx I want a result list that looks like this: Today xxxxxxxxxxxx xxxxxxxxxxxx xxxxxxxxxxxx Or Today Xxxxxxxxxxxx Yestarday xxxxxxxxxxxx xxxxxxxxxxxx Does anyone can help?Thanks in advance António <tr> <td><table width=220 cellpadding=2 cellspacing=0 border=0 style="position:relative; left:-10px"> <tr> <td width=19><img src="{$rel_url}images/folder_new_22.jpg" alt="" align="middle"></td> <td class="contentheader" nowrap>Documentos adicionados recentemente</td> </tr> </table></td> </tr> {section name="i" loop=$list} {if ($list.isViewer==1 || $isAdministrator)} {assign var="href_view" value=$rel_url|cat:"view.php?pid="|cat:$list.pid|escape:"html"} {else} {assign var="href_view" value=""} {/if} {if $list.thumbnail != "0" && $list.isViewer==1} {assign var="icon" value=$eserv_url|cat:"?pid="|cat:$list.pid|cat:"&dsID="|cat:$list.thumbnail} {else} {assign var="icon" value="images/record.jpg" } {/if} {if $isUser && ($list.isEditor==1 || $isAdministrator)} {assign var="showEdit" value=true} {else} {assign var="showEdit" value=false} {/if} {if $list.created_date} {if ($list.created_date.0|date_format:"%A") != $today} {if ($list.created_date.0|date_format:"%A") != $day_name} {assign var="day_name" value=$list.created_date.0|date_format:"%A"} {if $day_name == "Monday"}{assign var="day_name" value="Segunda-Feira"}{/if} {if $day_name == "Tuesday"}{assign var="day_name" value="Terça-Feira"}{/if} {if $day_name == "Wednesday"}{assign var="day_name" value="Quarta-Feira"}{/if} {if $day_name == "Thursday"}{assign var="day_name" value="Quinta-Feira"}{/if} {if $day_name == "Friday"}{assign var="day_name" value="Sexta-Feira"}{/if} {if $day_name == "Saturday"}{assign var="day_name" value="Sábado"}{/if} {if $day_name == "Sunday"}{assign var="day_name" value="Domingo"}{/if} <tr> <td> <table bgcolor="#FF6600" width="100%" cellpadding="3" cellspacing="0"> <tr> <td class="default_white"><strong>{$day_name}</strong> </td> </tr> </table> </td> </tr> {/if} {elseif $day_name != "Today"} {assign var="day_name" value="Hoje"} <tr> <td> <table bgcolor="#FF6600" width="100%" cellpadding="3" cellspacing="0"> <tr> <td class="default_white" ><strong>{$day_name}</strong> </td> </tr> </table></td> </tr> {/if} {/if} <tr> <td> <table bgcolor="#FFFFFF" width="100%" cellpadding="2" cellspacing="1" class="listrecord"> <tr> <td> {if $href_view}<a href='{$href_view}' >{/if}<img align="absmiddle" src="{$icon}" border="0">{if $href_view}</a>{/if} {if $href_view}<a href='{$href_view}'>{/if} {$list.title.0|escape:"html"}{if $href_view}</a>{/if} {if $showEdit || $isAdministrator} {if $showEdit} <a href='{$rel_url}workflow/update.php?pid={$list.pid|escape:"html"}&href={$smarty.server.REQUEST_URI}'><img title="Edit" align="absmiddle" src="{$rel_url}images/edit.gif" border="0"></a> {/if} {if $isAdministrator} <a href='javascript:void(null);' onClick="javascripturgeObject('{$list.pid|escape:"html"}');"><img title="Delete" align="absmiddle" src="{$rel_url}images/delete.gif" border="0"></a> {/if} {/if} {if $list.file_downloads}({$list.file_downloads.0|escape:"html"} Downloads){/if} </td> </tr> <tr> <td> {if $list.author}<b>{section name="author_loop" loop=$list.author}{assign var="next_author" value=$smarty.section.author_loop.index+1}<a class="author_link" href="list.php?browse=author&author={$list.author[author_loop]}">{$list.author[author_loop]|escape:"html"}</a>{if $list[i].author[$next_author] != ""} and {/if}{/section}</b>{if $list[i].date.0} {else}<br /> {/if}{/if}{if $list[i].date.0}({$list[i].date.0|date_format:"%Y"})<br /> {/if} {if $list[i].research_program.0}{$list[i].research_program.0|escape:"html"}{if $list[i].xdis_title.0 && $list[i].object_type.0 == '3'} - <i>{$list[i].xdis_title.0|escape:"html"}</i>{/if}<br /> {else}{if $list[i].xdis_title.0 && $list[i].object_type.0 == '3'}<i>{$list[i].xdis_title.0|escape:"html"}</i><br /> {/if}{/if} {if $list[i].description.0}{$list[i].description.0|escape:"html"}{if ($list[i].description.0|count_characters > 200)}...{/if}<br /> {/if} {if $list[i].object_type == '3' && $list[i].datastreams.0}<b>Files:</b> {section name="d" loop=$list[i].datastreams}{if $href_view}<a href="{$eserv_url|cat:"?pid="|cat:$list[i].pid|cat:"&dsID="|cat:$list[i].datastreams[d]}">{/if}{$list[i].datastreams[d]}{if $href_view}</a>{/if} {/section}{/if} </td> </tr> </table> <!-- space between rows --> </td> </tr> {sectionelse} <tr> <td class="default"><strong>(Nenhum item adicionado na última semana)</strong> </td> </tr> {/section} <tr>[/i][/i][/i][/i][/i][/i][/i][/i][/i][/i][/i][/i][/i][/i][/i][/i][/i][/i][/i][/i][/i]
$i = 0; while ($bla == bla) { if ($i == 0) { // do stuff, but only once } // do other fun stuff $i++; } PHP: Done.
Thanks for your reply, but I'm unable to implement your solution. Keep always getting errors... Can you help in implement your solution inside my code? My PHP is not advanced... António
that looks more like a smarty template than php, look on the smarty forums, standard php will not work, or be usefull to you ....
Don't bother telling us what errors you are getting. Guessing is way more fun! But yeah, if it's Smarty you'll have to adapt the code. I didn't bother looking at those hundreds of lines of code you pasted.