【www.gdgbn.com--php函数】

php smarty foreach 函数**/
  $tpl = new Smarty();
  $tpl->template_dir   = $cfg["path"]["template"];
  $tpl->compile_dir    = $cfg["path"]["root"] . "www.111cn.net/111cn/";
  
  $tpl->compile_check   = $cfg["debug"];
  $tpl->debugging      = false;
  $tpl->caching       = 0;
  $tpl->cache_lifetime  = 6000;
  
  $tpl->left_delimiter  = "";
  
//配置smarty

  $Db = new Db();
  try{
   $query = $Db->query($sql);
   if( $Db->rows( $query ) )
   {
    $array = $Db->fetch( $query,0 );
    foreach( $array as $v =>$_v )
    {    
     $List[$v]["id"] = $_v[0];     
     $List[$v]["cntitle"] = $_v[2];  
     $List[$v]["i"] = $i++;        
    }    
    
   }
    
  }catch( Execption $e ){
   MessAge("调用参失败!");
  }
//php 处理与程序
  tpl->assign("jsMenu_Deng", $List);
  
//下面为smarty模板处理foreach

 
 subcat[] = new Array("","","");

 var onecount=;
  
//其实很简单就是把数据用php保存到数据,然后再由smarty foreach 来实现。

 

?>

本文来源:http://www.gdgbn.com/jiaocheng/22684/