查询代码加入倒叙order by id desc 就查不出数据
渴望光荣 2016-08-02 11:57:22 加的目的是想要实现倒序排列,不加order by id desc 就可以查出数据,加了就查不出,问题在哪呢?
完整代码如下:
<?php
$link =mysql_connect("localhost","123456","123456");
mysql_select_db("123456", $link);
?>
<?php
//注释1-----------------------------
$xingming=$_POST["chinese"];
$tel=$_POST["mobile"];
$guhua=$_POST["phone"];
//注释2------------------------
$a=$b=$c='';
if($xingming != null){
$a = " and xingming like '%$xingming%'";}
if($tel != null){
$b = " and tel like '%$tel%'";}
if($guhua != null){
$c = " and guhua like '%$guhua%'";}
//注释3--------
$q = "SELECT * FROM dede_diyform1 where (1=1) oder by id desc"; //这里不加就能查出数据
$q .=$a.=$b.=$c;
//注释4----------------
mysql_query("SET NAMES UTF8");
$rs = mysql_query($q, $link);
echo "<table align='left' border='1' cellpadding='0' cellspacing='0' bordercolor='#A9A8A8' style='width:100%;'>";
echo "<tr><td width='68%' style='padding:5px 3px;'>货物信息</td><td width='30%' style='padding:5px 3px;'>物流信息</td></tr>";
while($row = mysql_fetch_object($rs)) echo "<tr><td style='padding:3px;'>区域:$row->area<br>单号:$row->danhao
<br>时间:".date('Y-m-d', $row->djtime+8*60*60)."<br>
货物:$row->huowu</td><td style='padding:5px 3px;'><a href='http://m.kuaidi100.com/index_all.html?type=$row->bianma&postid=$row->danhao&callbackurl=http://www.bj-bm.com/chaxun.php'>点击查看</a></td></tr>";
echo "</table>";
mysql_close($link);
?>
<?php
if (mysql_num_rows($rs) < 1)
echo "<script>alert('您暂时没有快递信息,如有疑问可咨询下方客服!');self.location='chaxun.php';</script>";
?>