PHP smarty Template Assignment problem

Source: Internet
Author: User
Tags smarty template
$arr = Array ([0]=>array ([goods_id]=>1[goods_name]=> phone [goods_price33]=>1000)] [1]=>array ([goods_id]= >2[goods_name]=> computer) [goods_price33]=>2000]);
$smarty->assign (' goods_list ', $arr);
?>


{foreach from= $goods _list item=goods}
{$goods. goods_id}
{$goods. Goods_name}
{$goods. goods_price33} normal display price 1000
{/foreach}


The 33 in question Goods_price33 is a variable that shows different values depending on the member ID
How to implement the changes in the template, try a lot of methods are not
Like what
$num =$_get[' id ']
$smarty->assign (num, $num);



{foreach from= $goods _list item=goods}
{$goods. goods_id}
{$goods. Goods_name}
{$goods. goods_price{$num}} is not normal, the browser displays {$goods. goods_price33}, the price cannot be displayed
{/foreach}


Reply to discussion (solution)

$num =$_get[' id ']
$smarty->assign (num, $num); You're here to judge that the user ID is not better

Logical things don't put them in the content.

$num =$_get[' id ']
$smarty->assign (num, $num); You're here to judge that the user ID is not better



This paragraph is in the PHP script file, but the assignment to the template loop will not work, other places normal

Logical things don't put them in the content.



is not put on the content, maybe I did not say clearly, that is separate, in PHP after assignment, the reference to the template loop does not show the value, other places can be displayed

You should get the ID of the member in PHP to display in the array, and then assign the value to the template, not directly assigned to the template.

  • Related Article

    Contact Us

    The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

    If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

    A Free Trial That Lets You Build Big!

    Start building with 50+ products and up to 12 months usage for Elastic Compute Service

    • Sales Support

      1 on 1 presale consultation

    • After-Sales Support

      24/7 Technical Support 6 Free Tickets per Quarter Faster Response

    • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.