如何把首页调用最新评论改为随机评论?
2016-07-07 14:55 来源:www.chinab4c.com 作者:ecshop专家
| 以下是我目前调用最新评论的库文件,求解如何修改为随机评论?有没有大牛帮忙解决下? 谢谢 <meta http-equiv="Content-Type" content="text/html; charset=utf-8"> <div class="globalModule" id="brandList"> <?php if(!function_exists("get_comments")){ function get_comments($num) { $sql = 'SELECT a.*,b.goods_id,b.goods_thumb,b.goods_name FROM '. $GLOBALS['ecs']->table('comment') . ' AS a,'. $GLOBALS['ecs']->table('goods') .'AS b WHERE a.status = 1 AND a.parent_id = 0 and a.comment_type=0 and a.id_value=b.goods_id '. ' ORDER BY a.add_time DESC'; if ($num > 0) { $sql .= ' LIMIT ' . $num; } //echo $sql; $res = $GLOBALS['db']->getAll($sql); $comments = array(); foreach ($res AS $idx => $row) { $comments[$idx]['add_time'] = local_date($GLOBALS['_CFG']['time_format'], $row['add_time']); $comments[$idx]['content'] = $row['content']; $comments[$idx]['id_value'] = $row['id_value']; $comments[$idx]['goods_thumb'] = get_image_path($row['goods_id'], $row['goods_thumb'], true); $comments[$idx]['goods_name'] = $row['goods_name']; } return $comments; } } ?> <!--数据调用-最新评论开始 --> <?php $this->assign('my_comments',get_comments(12)); // 数据条数 ?> <!--{foreach from=$my_comments item=comments}--> <li style="height: 60px; display: list-item;"> <div class="p-img ld"> <a rel="nofollow"href="goods-{$comments.id_value}.html" target="_blank" title="{$comments.goods_name}"><img src="{$comments.goods_thumb}" alt="{$comments.goods_name}" width="50" height="50"><b class="ci cix1"></b></a> </div> <div class="p-name"><a rel="nofollow" href="goods-{$comments.id_value}.html" target="_blank" title="{$comments.goods_name}">{$comments.goods_name}</a></div> <div class="p-detail"><a rel="nofollow" href="goods-{$comments.id_value}.html" target="_blank">{$comments.content}</a> </div> </li> <!--{/foreach}--> </div> | 
回答:
| order by rand() | 
| 其实调用最新的也可以呀 为什么要改呢 招募 友情链接 啊 | 
| 我也知道使用order by rand()但由于个人并不懂代码,不知道在哪里修改。。。 能不能指点指点? 谢谢 | 
| 直接在你的语句中ORDER BY a.add_time DESC 这句改掉 | 
| 哈, 非常感谢!使用你之前说的order by rand() 完美解决了 | 
| 我也遇到这个问题了....高手出来帮忙解答一下 | 
 
        
					
						
					
					
						
                          
					
				 
      
      最近更新
常用插件
- ecshop二次开发详细页面生
                                  插件介绍: ECSHOP系统,在很多时候,很多商品没有人购买,不但购买的人... 
- ecshop2.7.1打印发货单插件
                                  ecshop2.7.1打印发货单插件介绍:ecshop2.7.1和以前的ecshop版本不一样,ecs... 
- ecshop商品分类名称增加样
                                  ecshop插件介绍:本插件可以方便在后台管理,为ecshop商品分类名称增加样... 
- ecshop二次商品订购人信息
                                  ecshop二次商品订购人信息填写插件,有时候给朋友送花,或者是送礼品的... 
- ecshop分类批量扩展插件
                                  ecshop分类批量扩展插件,这个插件是ecshop插件里面比较核心的插件。我们... 
ecshop热门问答
ecshop热门资料
          
               
            ecshop成员 
                
            ecshop来安 
                
            ecshop聊天 
                
            dede模板 
                
            批量扩展 
                
            ecshop文章发布模块 
                
            ecshop升级问题 
                
            ecshop用品 
                
            ecshop显示超出 
                
            ecshop同类 
                
            ecshop状态码 
                
            ecshop内衣 
                
            ecshop商品包装 
                
            ecshop其它 
                
            ecshopparse 
                
            ecshop页面静态 
                
            ecshopprice 
                
            ecshopUnknow 
                
            ecshop管理器 
                
            ecshop激活码 
                
            ecshop画面 
                
            ecshop求证 
                
            ecshop深圳速汇通 
                
            ecshopapche 
                
            ecshopadmin 
                
            ecmall注册 
                
            ecshop运营 
                
            ecshop活动介绍 
                
            ecshop影音 
                
            ecshop编辑器 
             
        
      


