Home > Backend Development > PHP Tutorial > order by pid desc加到这个语句的那个位置?该怎么处理

order by pid desc加到这个语句的那个位置?该怎么处理

WBOY
Release: 2016-06-13 13:47:27
Original
923 people have browsed it

order by pid desc加到这个语句的那个位置?

PHP code
<!--

Code highlighting produced by Actipro CodeHighlighter (freeware)
http://www.CodeHighlighter.com/

--><?php $sql = "SELECT `subject`, `author`, `fid` ,`first`,`tid`,`pid`  FROM `forum_post` WHERE 1 ";
 $result = mysql_query($sql) or die("查询失败!");  
   $number = 6;
 while ($row=mysql_fetch_array($result)) 
 {
     if ($row['fid'] ==56 && $row['first'] !=0 && $number != 0)
     {
         ?>
         <tr>
            <td><a href="message/mes.php?id=<?php%20echo%20%24row%5B'pid'%5D;?>"><h3>
            <?php echo substr($row['subject'],0,64);$number--;?>
</h3></a></td>
               <td><a href="message/mes.php?id=<?php%20echo%20%24row%5B'pid'%5D;?>"><h3>
            <?php echo substr($row['author'],0,16);?>
</h3></a></td>
        </tr>
        <?php }
}?>
Copy after login



order by pid desc加到这个语句的那个位置?
$sql = "SELECT `subject`, `author`, `fid` ,`first`,`tid`,`pid` FROM `forum_post` WHERE 1 ";
我试了好几个地方都报错。
我需要让他降序排列

------解决方案--------------------
WHERE 1 之后
------解决方案--------------------
SELECT `subject`, `author`, `fid` ,`first`,`tid`,`pid` FROM `forum_post` WHERE 1
order by pid desc
------解决方案--------------------
语句最后,limit之前
Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template