开发者

How to Access Query Fetched from Oracle in PHP Smarty Template?

SO basiacally i have a query which i run and apply "while($item = oci_fetch_assoc($stid))开发者_高级运维" and i am confused how to take the rows seprately in one object and pass it to smarty template and show it in the table in smarty.


Build the entire rowset array, then pass that to your templating engine

$rowset = array();
while($item = oci_fetch_assoc($stid)) {
    $rowset[] = $item;
}

$smarty->assign($rowset); // Haven't used smarty in years, just guessing here


So basically we have to do something like : $i=1; while($row =oci_fetch_assoc($stid)){

    foreach($row as $key=>$value){
     $data_row[$i][$key]=$value;
    }
    $i++;
    }

SO this way $data_row[][] will be every entry and assign it to smarty. In Smarty we will access it by : {foreach from=$row key=myid item=foo} {$foo.key1} {$foo.key2} {$foo.key3} and so on {/foreach}

or whatever ur key is

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜