详情页

帝国cms截取当前文章标题匹配相关链接

时间:2024年04月10日

编辑:佚名

帝国cms如何截取当前文章标题匹配相关链接
<?php $v= mb_substr($navinfor[title],0,5,'UTF-8'); $id=$navinfor[id];?>
<?php
$ecms_bq_sql = sys_ReturnEcmsLoopBq("select * from phome_ecms_article where (title like '%$v%') and id<>$id order by newstime desc limit 8", 10, 24, 0);
$bqno = 0;
$hasOutput = false; 
while($bqr = $empire->fetch($ecms_bq_sql))
{
    $bqsr = sys_ReturnEcmsLoopStext($bqr);
    $bqno++;
    if(empty($bqr['title']) && $hasOutput) { 
        continue;
    }
    ?>
    <li>
        <a href="<?=$bqr['titleurl']?>" target="_blank" title="<?=$bqr['title']?>">
            <img src="<?=$bqr[titlepic]?$bqr[titlepic]:'/e/data/images/notimg.gif'?>" alt="<?=$bqr['title']?>">
            <p><?=$bqr['title']?></p>
        </a>
    </li>
    <?php
    if(!empty($bqr['title'])) {
        $hasOutput = true; 
    }
}
?>

<?php
if(!$hasOutput) { 
    $ecms_bq_sql = sys_ReturnEcmsLoopBq("select * from phome_ecms_article where id<>$id order by newstime desc limit 8", 10, 24, 0);
    $bqno = 0;
    while($bqr = $empire->fetch($ecms_bq_sql))
    {
        $bqsr = sys_ReturnEcmsLoopStext($bqr);
        $bqno++;
        ?>
        <li>
            <a href="<?=$bqr['titleurl']?>" target="_blank" title="<?=$bqr['title']?>">
                <img src="<?=$bqr[titlepic]?$bqr[titlepic]:'/e/data/images/notimg.gif'?>" alt="<?=$bqr['title']?>">
                <p><?=$bqr['title']?></p>
            </a>
        </li>
        <?php
    }
}
?>
截图如下:

 
相关文章
猜你需要