凉风有信,秋月无边
亏我思娇的情绪、好比度日如年

帝国cms内页sql语句根据关键词调用相关内容

文章摘要

这篇文章描述了一种使用PHP和Empire数据库框架从数据库中查询新闻数据的逻辑。代码通过条件判断(如`keyboard`标签的存在)和SQL查询,从数据库中提取新闻标题、图片和时间戳,并将其以HTML格式呈现。文章的重点在于数据查询的条件构造和结果展示的动态生成。
<?php
if ($navinfor['keyboard'])
{
$c_key=explode(',',$navinfor['keyboard']);
$count=count($c_key);
for($i=0;$i<$count;$i++)
{
if($i==0)
{
$or='';
}
else
{
$or=' or ';
}
$repadd.=$or."keyboard like '%".$c_key[$i]."%'";
}
$r=$empire->fetch1("select * from {$dbtbpre}ecms_news where id<>".$navinfor['id']." and ".$repadd." order by newstime desc limit 1");
if($r[title])
{
$mesql=$empire->query("select titleurl,title,titlepic,newstime from {$dbtbpre}ecms_news where id<>".$navinfor['id']." and ".$repadd." order by newstime desc limit 12");
while($or=$empire->fetch($mesql))
{
$newstime=date('Y-m-d',$or[newstime]);
?>
<li><a href="<?=$or[titleurl]?>"><img data-src="<?=$or[titlepic]?>" alt="<?=$or[title]?>" src="https://www.1004619.com/wp-content/themes/dux/img/thumbnail.png" class="thumb"></a><a href="<?=$or[titleurl]?>"><?=$or[title]?></a></li>
<?
}
}
else
{

$mesql2=$empire->query("select * from {$dbtbpre}ecms_news where id<>".$navinfor['id']." order by rand() desc limit 12");
while($r2=$empire->fetch($mesql2))
{
$newstime=date('Y-m-d',$o2[newstime]);
?>
<li><a href="<?=$or[titleurl]?>"><img data-src="<?=$or[titlepic]?>" alt="<?=$or[title]?>" src="https://www.1004619.com/wp-content/themes/dux/img/thumbnail.png" class="thumb"></a><a href="<?=$or[titleurl]?>"><?=$or[title]?></a></li>
<?
}
}
}
else
{
$mesql2=$empire->query("select titleurl,titlepic,title,newstime from {$dbtbpre}ecms_news   order by rand()  desc limit 12");
while($r2=$empire->fetch($mesql2))
{
$newstime=date('Y-m-d',$r2[newstime]);
?>
<li><a href="<?=$or[titleurl]?>"><img data-src="<?=$or[titlepic]?>" alt="<?=$or[title]?>" src="https://www.1004619.com/wp-content/themes/dux/img/thumbnail.png" class="thumb"></a><a href="<?=$or[titleurl]?>"><?=$or[title]?></a></li>
<?
}
}
?>

 

赞(0) 打赏
版权声明:本文采用知识共享 署名4.0国际许可协议 [BY-NC-SA] 进行授权
文章名称:《帝国cms内页sql语句根据关键词调用相关内容》
文章链接:https://www.1004619.com/biji/20230801211.html
本站资源仅供个人学习交流,请于下载后24小时内删除,不允许用于商业用途,否则法律问题自行承担。

评论 抢沙发

觉得文章有用就打赏一下文章作者

非常感谢你的打赏,我们将继续提供更多优质内容,让我们一起创建更加美好的网络世界!

支付宝扫一扫

微信扫一扫