使用 ThinkPHP 在 controller 抓到資料

public function product()
{
    $oProductList = Product::select();
    $this->view->assign('oProductList', $oProductList);
    return $this->view->fetch();
}

後 想套用在 HTML 使用 forloop

{volist name="oProductList" id="oProduct" key="key"}
    {$oProduct.id} - {$key}<br/>
{/volist}
<!--
    輸出:
    1 - 1
    2 - 2
    3 - 3
    4 - 4
-->

 

 

文章標籤
全站熱搜
創作者介紹
創作者 benny 的頭像
benny

Benny的網站開發筆記

benny 發表在 痞客邦 留言(0) 人氣(2)