温馨提醒

如果文章内容或图片资源失效,请留言反馈,我们会及时处理,谢谢

本文最后更新于2023年10月30日,已超过 180天没有更新

查询SQL:

<?php
//上下翻页
$goPage = [
    'prev'        => ['text' => '上一题'],
    'next'         => ['text' => '下一题']
];
$sql = $empire->query("(SELECT titleurl, id, title FROM `{$dbtbpre}ecms_news` WHERE `id` < " . $navinfor['id'] . " AND `classid` = " . $navinfor['classid'] . " ORDER BY `id` DESC LIMIT 1) UNION (SELECT titleurl, id, title FROM `{$dbtbpre}ecms_news` WHERE `id`> " . $navinfor['id'] . " AND `classid` = " . $navinfor['classid'] . " ORDER BY `id` LIMIT 1)");
if(0 < $empire->num1($sql)) {
        while($r = $empire->fetch($sql)){
        $key = isset($r['id']) && $r['id'] > $navinfor['id'] ? 'next' : 'prev';
        $goPage[$key]['title']                 = $r['title'];
        $goPage[$key]['titleurl']         = sys_ReturnBqTitleLink($r);
        }
}
?>

显示代码:

<?php foreach($goPage as $type => $page):?>
    
      <div class="col-sm-6 mb-5">
        <div class="card">
          <div class="card-body position-relative">
                      <?php if(isset($page['title'])):?>
                      <a href="<?php echo $page['titleurl'];?>" tltle="<?php echo $page['title'];?>" class="btn btn-danger stretched-link"><?php echo $page['text'];?></a>
                      <?php else:?>
                      <a href="javascript:;" class="btn btn-primary disabled" role="button" aria-disabled="true"><?php echo $page['text'];?></a>
                      <?php endif;?>
             
          </div>
        </div>
      </div>
    <?php endforeach;?>

 

声明:本站所有文章,如无特殊说明或标注,均为本站原创发布。任何个人或组织,在未征得本站同意时,禁止复制、盗用、采集、发布本站内容到任何网站、书籍等各类媒体平台。如若本站内容侵犯了原著者的合法权益,可联系我们进行处理。