Помощ с алгоритъм в 1 код

qazxsw

Registered
Имам следнияд код за изкарване на 4 произволни препоръки написани от клиенти.

index.php
PHP:
//Getting 4 random results from the database
$sql = mysql_query("SELECT * FROM `testimonials` ORDER BY RAND() LIMIT 0,4");

//Putting the results into an array
while($row = mysql_fetch_array($sql)){
	//Putting the result into a smarty array
	$result[] = $row;}

//Assing some smarty variables
$smarty->assign("result",$result); //4 random testimonials 

//Display the template file
$smarty->display("index.tpl");

index.tpl
Код:
					<h1>What do our clients think?</h1>
						{foreach item="r" from="$result"}
							<div class="one_fourth"><h6>{$r.client}</h6><p>{$r.testimonial|truncate:125}</p>
							</div>
						{/foreach}

Там където започва самият div "<div class="one_fourth">" на четвъртият резултат които ми изкара трябва да добави last или по-точно да стане така:

Код:
<div class="one_fourth last"></div>
 
bancov96 каза:
Код:
{if $smarty.foreach.r.last}
    <div id="last">{$r.client}</div>
{/if}

Мерси за кода, но си дал този за версия 2.

@Karcho, и ти си дал този за версия 2, но от линка ти днес се оправих на работа, мерси и +1 :)
 

Back
Горе