我的mysql查询中的订单有问题。没有“WHERE adder
='$ followuser'”查询工作正常。但是WHERE是ORDER BY无法正常工作。你能帮我吗? :)
这是我的代码:
$time=time();
$checkfollowing=mysql_query("SELECT * FROM `follow` WHERE `follower`='$session'") or die(mysql_error()); /* Check if is user following somebody */
if(mysql_num_rows($checkfollowing) == FALSE){ /* He's following no one */
echo "You follow noone";
die();
}elseif(mysql_num_rows($checkfollowing) == TRUE){ /* He's following somebody */
while($row11=mysql_fetch_array($checkfollowing)){
$followuser=$row11['get_follow'];
$fcontent=mysql_query("SELECT * FROM `followcontent` WHERE `adder`='$followuser' ORDER BY id DESC") or die (mysql_error()); /* Follow content */
while($row=mysql_fetch_assoc($fcontent)){
$id=$row['id'];
$photourl=$row['photourl'];
$adder=$row['adder'];
echo "<hr class='style'><br><div id='newadder'>".$adder."</div><a href='photo/?id=".$id."'><img src='".$photourl."' class='newfolimg'></a>";
}
} }
非常感谢你:))
答案 0 :(得分:4)
如果id
的数据类型为string
,则会在lexicographical order中对其进行排序。试试这个技巧,
ORDER BY id * 1 ASC
MySQL会隐式将列转换为数字。如果该值以字母开头,则相应的值将为0
。
答案 1 :(得分:0)
可能WHERE子句将结果限制为一行,这就是为什么“不工作”。