开发者

MYSQL query not working as expected

I have the following mysql query---

               $query="SELECT * FROM `wall_posts`
                       WHERE 
                       `login_name` = '" . $_SESSION['SESS_LOGIN'] . "'
                       OR
                       `login_name` IN (
                       SELECT friend_login
                       FROM friends
                       )
                       ORDER BY time DESC";

But when I execute it,开发者_如何学编程 it does'nt give me expected results also only one post is being displayed!


Have you tried running it directly from within a mysql console/phpmyadmin?
And what is in friends? Is it a relation table? In that case you should probably add a WHERE somewhere because now you are selecting everything.

This code should return more then just 1 row if there are more. Perhaps your problem is in the way you display the results. What is the result of:

$result = mysql_query($query);
echo 'Number of rows: ' . mysql_num_rows($result);
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜