/*热销产品*/ 
$re1s = $db->query("select * from {$prefix}_product order by compositor desc,id asc limit 2");
while($re1r = $db->getarray($re1s)) {
$product[] = smarrayall($re1r);
}
$smarty->assign("product", $product);  我朋友给我一个程序,我看看,首页都是调用模板的,求上面的详解,越细越好,完事立马给分!!!哈哈哈,高手们帮帮小弟。

解决方案 »

  1.   

    //执行一个sql,目标,根据compositor 大到小,但是id小到大的方式找符合条件的2个结果
    $re1s = $db->query("select * from {$prefix}_product order by compositor desc,id asc limit 2");
    while($re1r = $db->getarray($re1s)) {//循环取值
    $product[] = smarrayall($re1r);//把值保存在$product数组
    }
    $smarty->assign("product", $product);   //应该是smarty模板赋值,以便页面输出$product的结果
      

  2.   

    从产品表 product 里 根据 compositor ,id 倒序 取出两条记录
    用  $product[] = smarrayall($re1r); 把记录的详细信息存到 $product[] 数组中然后 用 $smarty->assign("product", $product);   赋值给 product 前台页面调用product
      

  3.   

    $re1s = $db->query("select * from {$prefix}_product order by compositor desc,id asc limit 2");//sql语句:查询表{$prefix}_product按照compositor倒序排序---降序,id升序(order by compositor desc,id asc),获取两条记录(limit 2)
    while($re1r = $db->getarray($re1s)) {//将查询数据库所返回的资源循环(while)转型(变成数据),直到所有资源遍历完毕
    $product[] = smarrayall($re1r);//将转型后的数据放到数组($product)中
    }
    $smarty->assign("product", $product);//这个用的是smarty模板,这句的意思是在smarty模板中用$product(product)调用
      

  4.   


    $smarty->assign('act', $act);
    $setuplist = smarrayall($setup);
    $smarty->assign('setup', $setuplist); // 定义显示数组
    $smarty->display('skins/default/index.html');
    这个assion是什么意思?
      

  5.   

    $smarty->assign('setup', $setuplist);  
    后台 定义的 $setuplist 不能直接在前台显示
    需要assign 到setup 中 在前台 用setup
      

  6.   


    你可以将assign('var_smarty', $var_php)看做是赋值操作,将后面的var_php变量赋给模板中的var_smarty变量,就像一个中转站似的,将php变量转变成smarty变量 
      

  7.   

    $re1s = $db->query("select * from {$prefix}_product order by compositor desc,id asc limit 2");
    //$re1s:这里是一个变量,用于接收后面$db对象的query方法执行出来的结果集
    //$db:这里是一个对象的变量
    //query:$db对象的方法,这里应该是用于执行sql语句的方法。
    //select * from {$prefix}_product order by compositor desc,id asc limit 2
    //select: 查询
    //* :表示所有字段
    //from {$prefix}_product: 从{$prefix}_product表里查询
    //{$prefix} :这里是系统中用于设置表前缀的变量
    //order by: 进行排序
    //compositor desc :compositor 倒序排列
    //id asc:id 顺序排列
    //limit 2:从被排序的结果中取头两条数据
    ***********************************************************我要疯了,没下次了。