문제

I have the following PHP function

while( $manufacturer2 = xtc_db_fetch_array($manufacturer_query2,true) ){
echo $manufacturer2['manufacturers_name'] = '<a class="PI_Manufacturer"
href="'. xtc_href_link(FILENAME_DEFAULT, xtc_manufacturer_link($manufacturer2['manufacturers_id'])) . '">' . $manufacturer2['manufacturers_name'] . '</a>';
}

Right now it echoes the results but I want to assign them to a Smarty variable. I put this:

$info_smarty->assign('MANUFACTURERS',$manufacturer2['manufacturers_name']);

in the while loop but when I call my variable in the template I get only 1 name instead of 2 or 3 for example. In my templates I'm using a foreach loop to get all the values. Any suggestions?

도움이 되었습니까?

해결책 2

Here is how I solved this:

Created an array in the while loop and put each item in it:

while( $manufacturer2 = xtc_db_fetch_array($manufacturer_query2,true) ){
$os[] = $manufacturer2['manufacturers_name'] = '<a class="PI_Manufacturer" style="color: #990033" href="' . xtc_href_link(FILENAME_DEFAULT, xtc_manufacturer_link($manufacturer2['manufacturers_id'],$manufacturer2['manufacturers_name'])) . '">' . $manufacturer2['manufacturers_name'] . '</a><text class="PI_Manufacturer">;</text> ';
$info_smarty->assign('ALINK',$os);
}

I also assigne the array to a variable at the end and called it using a foreach loop in the template:

{foreach item=authors from=$ALINK} 
{$authors}
{/foreach}

다른 팁

since you are using a single variable to store bvalues, that is wwhy you are getting only single value. try using smarty arrays to assign values.

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top