SELECT * FROM tablename ORDER BY id DESC LIMIT 2, 1 // id是主键递增,按倒序排列。LIMIT 2,1 取第3条数据
$sqlhot="select * from news where ntype='2' order by nid desc"; 你看哈应该怎么改,才能去除倒数第二、第三、第四, 还有里面有一个字段是ndate的,要怎么样才可以只取出nadate里面的‘天’月和年都不要,然后取出‘月’天和年不要,但是‘月’的要变成英文,怎么搞?谢谢
$sqlhot="select * from news where ntype='2' order by nid desc"; 你看哈应该怎么改,才能取出倒数第二、第三、第四, 还有里面有一个字段是ndate的,要怎么样才可以只取出nadate里面的‘天’月和年都不要,然后取出‘月’天和年不要,但是‘月’的要变成英文,怎么搞?谢谢
$sqlhot="select .....,day(nadate),monthname(nadate) from news where ntype='2' order by nid desc limit 1,3";
$sqlhot="select .....,day(nadate),monthname(nadate) from news where ntype='2' order by nid desc limit 1,3"; 怎么得到天和月,然后再怎么输出?
$sqlhot="select .....,day(nadate),monthname(nadate) from news where ntype='2' order by nid desc limit 1,3"; $rs=$obj->fetchrow($sqlhot1); $ndate=$rs->ndate; 这样写获得对不? 然后输出是 <?=$ndate('d');?> 但是这样好像不对啊?出错啦!
$sqlhot="select nid,ntitle,ntype,day(ndate),monthname(nadate) from news where ntype='2' order by nid desc"; $rs=$obj->fetchrow($sqlhot); $nid=$rs->nid; $ntitle=$rs->ntitle; $nword=$rs->nword; $ndate=$rs->ndate; $ntype=$rs->ntype; 这样你看对不?但是我不知道怎么取得day(ndate),monthname(nadate),先不循环,这样我看懂点,慢慢来,谢谢啊!
哦。我明白你的意思了。取个别名。 $sqlhot="select nid,ntitle,ntype,day(ndate) as d,monthname(nadate) as m from news where ntype='2' order by nid desc";取时: ......... $ntype=$rs->d; $ntype=$rs->m;
$sqlhot="select nid,ntitle,ntype,day(ndate) as d,monthname(nadate) as m from news where ntype='2' order by nid desc"; $rs=$obj->fetchrow($sqlhot); $nid=$rs->nid; $ntitle=$rs->ntitle; $nword=$rs->nword; $ndate=$rs->ndate; $ntype=$rs->ntype; $month=$rs->m; $day=$rs->d; 这样写你看对吗?但是出现了这样的错误 mysql Error: 1054 select nid,ntitle,ntype,day(ndate) as d,monthname(nadate) as m from news where ntype='2' order by nid desc
他就提示是这样的 mysql Error: 1054 select nid,ntitle,ntype,day(ndate) as d,monthname(nadate) as m from news where ntype='2' order by nid desc 然后什么都没有
// id是主键递增,按倒序排列。LIMIT 2,1 取第3条数据
你看哈应该怎么改,才能去除倒数第二、第三、第四,
还有里面有一个字段是ndate的,要怎么样才可以只取出nadate里面的‘天’月和年都不要,然后取出‘月’天和年不要,但是‘月’的要变成英文,怎么搞?谢谢
你看哈应该怎么改,才能取出倒数第二、第三、第四,
还有里面有一个字段是ndate的,要怎么样才可以只取出nadate里面的‘天’月和年都不要,然后取出‘月’天和年不要,但是‘月’的要变成英文,怎么搞?谢谢
怎么得到天和月,然后再怎么输出?
$rs=$obj->fetchrow($sqlhot1);
$ndate=$rs->ndate;
这样写获得对不?
然后输出是 <?=$ndate('d');?>
但是这样好像不对啊?出错啦!
$rs=$obj->fetchrow($sqlhot);
$nid=$rs->nid;
$ntitle=$rs->ntitle;
$nword=$rs->nword;
$ndate=$rs->ndate;
$ntype=$rs->ntype;
这样你看对不?但是我不知道怎么取得day(ndate),monthname(nadate),先不循环,这样我看懂点,慢慢来,谢谢啊!
$sqlhot="select nid,ntitle,ntype,day(ndate) as d,monthname(nadate) as m from news where ntype='2' order by nid desc";取时:
.........
$ntype=$rs->d;
$ntype=$rs->m;
$rs=$obj->fetchrow($sqlhot);
$nid=$rs->nid;
$ntitle=$rs->ntitle;
$nword=$rs->nword;
$ndate=$rs->ndate;
$ntype=$rs->ntype;
$month=$rs->m;
$day=$rs->d;
这样写你看对吗?但是出现了这样的错误
mysql Error: 1054
select nid,ntitle,ntype,day(ndate) as d,monthname(nadate) as m from news where ntype='2' order by nid desc
mysql Error: 1054
select nid,ntitle,ntype,day(ndate) as d,monthname(nadate) as m from news where ntype='2' order by nid desc
然后什么都没有
字段: nid、ntitle、ntype、ndate
就这么多然后就要查看所有的,可是ndate是自己写的时间2012-03-25,现在要显示2012-03-25的25,还有2012-03-25的月份03,但是03要变成大写的mat,这样你看应该这么写代码?谢谢啊。