欢迎访问 舍力博客(www.shuyong.net)
<?php //shuyong.net:同分类相邻文章 function nextLog($logid, $sortid, $flag, $pattern=0){ $Log_Model = new Log_Model();if($flag == 'prev'){$sql = " AND gid < $logid ORDER BY gid DESC";$word = '上一篇';} else{$sql = " AND gid > $logid ORDER BY gid ASC";$word = '下一篇';} $log = $Log_Model -> getLogsForHome(" AND sortid = $sortid "."$sql", 1, 1); if($log){foreach($log as $value):?> <?php echo $word;?>:<a href="<?php echo $value['log_url'];?>" title="<?php echo $value['log_title'];?>"><?php echo $value['log_title'];?></a> <?php endforeach;}else{echo $word.':没有了'; } }?>然后在echo_log.php相应位置放入
<?php nextLog($logid, $sortid, 'prev'); nextLog($logid, $sortid, 'next');?>这样,我们就实现了调用同一分类下的相邻日志了!
留言/评论:◎欢迎参与讨论,请在这里发表您的看法、交流您的观点。