作业帮 > 综合 > 作业

$sql_notice = "select * from $t_article art inner join $t_ar

来源:学生作业帮 编辑:作业帮 分类:综合作业 时间:2024/05/14 03:02:05
$sql_notice = "select * from $t_article art inner join $t_article_cat cat where art.cat_id=cat.cat_id and cat.cat_id='$ncat_id' and cat.is_show=1 and art.is_show=1 order by art.short_order desc limit 0,10";
这句代码哪里错了,为什么降序实现不了?
$sql_cat = "select * from $t_article_cat where is_show=1 and shop_id='$shop_id' order by sort_order asc limit 0,1";
$cat_notice = $dbo->getRs($sql_cat);
foreach($cat_notice as $value){
$ncat_id=$value['cat_id'];
$sql_notice = "select * from $t_article art inner join $t_article_cat cat where art.cat_id=cat.cat_id and cat.cat_id='$ncat_id' and cat.is_show=1 and art.is_show=1 order by art.short_order desc limit 0,10";
$notice = $dbo->getRs($sql_notice);
你没有设置连接关系 on art.cat_id=cat.cat_id ,修改如下
$sql_notice = "select art.* ,cat.* from ".$t_article." art inner join ".$t_article_cat." cat on art.cat_id=cat.cat_id where cat.cat_id='".$ncat_id."' and cat.is_show=1 and art.is_show=1 order by art.short_order desc limit 0,10";
echo $sql_notice;
再问: 还是没有变。。
再答: 你把 echo $sql_notice 的 sql在 查询分析器中 执行 看看 就知道了, 语句中 是 按照short_order 字段的降序排列的