Jump to content

Recommended Posts

Usually I prefer to search the internet instead of Posting it somewhere! But This time I am stuck ...  :shrug: .... I got no other option when such simple statement isn't giving expected response!

 

To the point.. What I want to do is to get the posts from table "user_post" where

 

1. (postby = current user && postfor=NULL)

2. OR (postfor = Current User)

 

to display on users wall...

 

The code looks like this..

 

mysql_query(" SELECT * FROM user_post WHERE ( (postby='$cur_user_id' && postfor=NULL) || (postfor='$cur_user_id') )  ORDER BY postdate DESC LIMIT $num_posts") 
					or die(mysql_error()); 

 

But all it gives is the postfor= current user

 

Somebody plz take me out of this pit!!!  :confused: 

Link to comment
https://forums.phpfreaks.com/topic/211981-struggling-with-where-clause/
Share on other sites

Nothing is ever equal to NULL, not even another NULL.  You have to use 'IS NULL'

 

mysql_query(" SELECT * FROM user_post 
WHERE ( (postby='$cur_user_id' && postfor IS NULL) || (postfor='$cur_user_id') )  
ORDER BY postdate DESC LIMIT $num_posts")
                  or die(mysql_error()); 

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.