Discuz!官方免费开源建站系统

 找回密码
 立即注册
搜索

[疑难] 有谁会PHP,有个难题希望能指点迷津

[复制链接]
秋之子 发表于 2009-3-14 16:50:45 | 显示全部楼层 |阅读模式
本帖最后由 秋之子 于 2009-3-14 17:07 编辑

下面是一段调用ECMALL的PHP代码,我直接用echo输出能显示结果
但我想结合在模板中,用<!--{loop $mall_new $value}-->
这个来调用
但不显示数据 ,请问哪里有错呢?
  1. //获取产品属性
  2. function get_mall_spec($goods_id,$db){
  3.         $strSql="select * from ecm_goods_spec where goods_id=$goods_id limit 0,1";
  4.         $query=$db->query($strSql);
  5.         if ( $iteminfo = $db->fetch_array( $query ) ) {
  6.                 $iteminfo['image']=get_thumb_img($iteminfo['default_image']);
  7.                 return $iteminfo;
  8.         }               
  9.         return null;
  10. }

  11. //获取缩略图路径
  12. function get_thumb_img($d){
  13.         define('ECM_KEY','63f102254c6fbe018590f4c0a6e0b5fc');
  14.         $arr=array('file'=>$d,'width'=>120,'height'=>120);
  15.         $hash_path = md5( ECM_KEY.$arr['file'].$arr['width'].$arr['height'] );
  16.         $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";
  17.         return $thumb_path;
  18. }

  19. //最新的推荐图片产品
  20. $strSql="select * from ecm_goods where is_mi_best=1 order by last_update desc limit 0,18";
  21. $query = $_SGLOBAL['db']->query($strSql);
  22. while ($item = $_SGLOBAL['db']->fetch_array($query)) {
  23.         $item['spec']=get_mall_spec($item['goods_id'],$_SGLOBAL['db']);
  24.         $item['jieshen']=$item['spec']['market_price']-$item['spec']['store_price'];
  25.         $mall_new[] = $item;
  26. }
复制代码
回复

使用道具 举报

 楼主| 秋之子 发表于 2009-3-14 17:07:25 | 显示全部楼层
老在这里帮助 别人,自己好不容易有回困难没有人帮我了
哭呀
回复

使用道具 举报

304558580 发表于 2009-3-14 17:36:38 | 显示全部楼层
((mk06))  上面的代码没错
回复

使用道具 举报

51shidai 发表于 2009-3-14 17:43:53 | 显示全部楼层
代码确实没错的。..但是调用是不能这么调用的.
回复

使用道具 举报

 楼主| 秋之子 发表于 2009-3-14 17:47:14 | 显示全部楼层
4# 51shidai


怎么调用呢?第一次弄PHP代码,以前光会看不会写, 现在写上了,但不会调用
指点下啦
回复

使用道具 举报

 楼主| 秋之子 发表于 2009-3-14 18:15:54 | 显示全部楼层
人呢?都跑哪去啦。。。
回复

使用道具 举报

51shidai 发表于 2009-3-14 18:21:05 | 显示全部楼层
人都飞的了.........
回复

使用道具 举报

 楼主| 秋之子 发表于 2009-3-14 18:22:12 | 显示全部楼层
7# 51shidai


你给说下嘛,
回复

使用道具 举报

超级黄金马甲 发表于 2009-3-14 19:55:54 | 显示全部楼层
  1. //最新的推荐图片产品

  2. $strSql="select * from ecm_goods where is_mi_best=1 order by last_update desc limit 0,18";

  3. $query = $_SGLOBAL['db']->query($strSql);
  4. $mall_new = $_SGLOBAL['db']->fetch_array($query);
复制代码
回复

使用道具 举报

benba 发表于 2009-3-14 21:27:29 | 显示全部楼层
<!--{loop $mall_new  $value}-->
            <li><a href="$value[url]">$value[subject]</a></li>
<!--{/loop}-->

这好像才是基本方法.上面只是一个示例.你用打印出来的数据索引值放到[]里就可以调用相应的东西出来了!
回复

使用道具 举报

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

手机版|小黑屋|Discuz! 官方站 ( 皖ICP备16010102号 )star

GMT+8, 2025-10-22 01:18 , Processed in 0.102561 second(s), 14 queries , Gzip On.

Powered by Discuz! X3.4

Copyright © 2001-2023, Tencent Cloud.

快速回复 返回顶部 返回列表