分享

ecshop首页调用评论函数(index.php)

 quasiceo 2014-05-03

ecshop首页调用评论函数(index.php)

(2012-02-21 14:57:07)
标签:

取得

调用

函数

记录

杂谈

分类: ecshop

1.
function comments_info($count=1)
{
    $sql = "SELECT g.goods_id,g.goods_name,g.goods_thumb,tb.ct FROM ".
 $GLOBALS['ecs']->table('goods'). " g join".
 "(select  id_value id,count(*) ct from ".
 $GLOBALS['ecs']->table('comment')."  where comment_type=0 and status=1  group by id_value) tb ".
 "on g.goods_id=tb.id ";
 if(!empty($count)) $sql.=" limit 0,".$count; 
    $res = $GLOBALS['db']->getAll($sql);
 $arr = array();
    foreach ($res AS $i => $row)   
    
       $arr[$i]['goods_id']=$row['goods_id'];
    $arr[$i]['goods_name']=$row['goods_name'];
    $arr[$i]['count']=$row['ct'];
    $arr[$i]['goods_thumb']=$row['goods_thumb']; 
    $arr[$i]['comment']= get_comment($row['goods_id']);
    }
    return $arr;
}

function get_comment($goodid=0)
{
 $sql = "SELECT * FROM ". $GLOBALS['ecs']->table('comment')." WHERE `id_value`=".
 $goodid." and status=1  order by `parent_id`,`add_time` LIMIT 0,4";
    return $GLOBALS['db']->getAll($sql);
}

 

2.

$smarty->assign('comment_list',    comments_info(10));        // 商品评论 

 

3.

<!--商品评论开始{if $comment_list}-->

 <div style="overflow:hidden;height:190px;" id="demo">
 <div id="demo1">
     <ul>
 <!--{foreach from=$comment_list item=comm}-->
    <li>  
        <div class="fl"><a href="goods.php?id={$comm.goods_id}" title="{$comm.goods_name}" target="_blank">
        <img  alt="{$comm.goods_name}" src="{$comm.goods_thumb}" style="width:80px;"></a>
        </div>
        <div class="fl " style="padding-top:5px;width:350px;">
           
        <!--{foreach from=$comm.comment item=info}-->
          <!--{if $info.user_name}-->
         <font class="bl" >{$info.user_name}</font>:<a href="goods.php?show=a&id={$comm.goods_id}"  target="_blank"> {$info.content}</a> <br/>  
         <!--{/if}-->    
        <!--{/foreach}-->
        </div>
    </li>  
    <!--{/foreach}-->
    </ul> 
    </div>
    <div id="demo2"></div> 
    </div>


<!--商品评论结束{/if}-->

    本站是提供个人知识管理的网络存储空间,所有内容均由用户发布,不代表本站观点。请注意甄别内容中的联系方式、诱导购买等信息,谨防诈骗。如发现有害或侵权内容,请点击一键举报。
    转藏 分享 献花(0

    0条评论

    发表

    请遵守用户 评论公约

    类似文章 更多