本帖最后由 秋之子 于 2009-3-14 17:07 编辑
下面是一段调用ECMALL的PHP代码,我直接用echo输出能显示结果
但我想结合在模板中,用<!--{loop $mall_new $value}-->
这个来调用
但不显示数据 ,请问哪里有错呢?- //获取产品属性
- function get_mall_spec($goods_id,$db){
- $strSql="select * from ecm_goods_spec where goods_id=$goods_id limit 0,1";
- $query=$db->query($strSql);
- if ( $iteminfo = $db->fetch_array( $query ) ) {
- $iteminfo['image']=get_thumb_img($iteminfo['default_image']);
- return $iteminfo;
- }
- return null;
- }
- //获取缩略图路径
- function get_thumb_img($d){
- define('ECM_KEY','63f102254c6fbe018590f4c0a6e0b5fc');
- $arr=array('file'=>$d,'width'=>120,'height'=>120);
- $hash_path = md5( ECM_KEY.$arr['file'].$arr['width'].$arr['height'] );
- $thumb_path = "http://localhost/nihao/mall/temp/thumb/".$hash_path[0].$hash_path[1]."/".$hash_path[2].$hash_path[3]."/".$hash_path.$arr['file'].".jpg";
- return $thumb_path;
- }
- //最新的推荐图片产品
- $strSql="select * from ecm_goods where is_mi_best=1 order by last_update desc limit 0,18";
- $query = $_SGLOBAL['db']->query($strSql);
- while ($item = $_SGLOBAL['db']->fetch_array($query)) {
- $item['spec']=get_mall_spec($item['goods_id'],$_SGLOBAL['db']);
- $item['jieshen']=$item['spec']['market_price']-$item['spec']['store_price'];
- $mall_new[] = $item;
- }
复制代码 |