doubledee Posted June 1, 2012 Share Posted June 1, 2012 How do I change this code... // Build query. $q3 = "SELECT requestor, username, photo_name, photo_label, requestee_approved FROM friend AS f INNER JOIN member AS m ON f.requestor=m.id WHERE requestee=? AND requestor_approved=1 AND requestee_approved=0"; ...so that I can see... WHERE requestee=? AND requestor_approved=1 AND (requestee_approved=0 OR requestee_approved=2) I'm not sure how to do an "OR" in SQL, and I believe there are a few ways to do it, right? Debbie Quote Link to comment https://forums.phpfreaks.com/topic/263470-show-2-values-in-query/ Share on other sites More sharing options...
Barand Posted June 1, 2012 Share Posted June 1, 2012 First rule when using OR is to use paretheses to remove ambiguity Instead of A AND B OR C use (A AND B) OR C or A AND (B OR C) Secondly. if you have WHERE (x = 1) OR (x=2) OR (x=3) it is easier to have WHERE x IN (1,2,3) Quote Link to comment https://forums.phpfreaks.com/topic/263470-show-2-values-in-query/#findComment-1350232 Share on other sites More sharing options...
doubledee Posted June 1, 2012 Author Share Posted June 1, 2012 First rule when using OR is to use paretheses to remove ambiguity Instead of A AND B OR C use (A AND B) OR C or A AND (B OR C) Secondly. if you have WHERE (x = 1) OR (x=2) OR (x=3) it is easier to have WHERE x IN (1,2,3) Somewhat off topic, but what do you think about this from a design standpoint... I have a Form/Page which displays all incoming Friend-Requests for the logged in Member. There is the Requesting User's: Username, Photo, and 3 Radio Buttons ("Decide later", "Accept", Decline") The way my page is coded now, when new Friend-Requests come in, everything defaults to "Decide Later". If the User doesn't do anything, the next time the Form loads it will be as is. If the User chooses "Accept" for a Requestee, then their name disappears off this Friend-Request List. If the User chooses "Decline", the same thing happens. The point is, that I have a "one trick pony" and I am wondering if I should make it so you can always see what you chose? Follow me? Debbie Quote Link to comment https://forums.phpfreaks.com/topic/263470-show-2-values-in-query/#findComment-1350234 Share on other sites More sharing options...
Barand Posted June 1, 2012 Share Posted June 1, 2012 I'm assuming you can already show a list of (accepted) friends so all you would need to add is an option to list declined friend requests Quote Link to comment https://forums.phpfreaks.com/topic/263470-show-2-values-in-query/#findComment-1350239 Share on other sites More sharing options...
doubledee Posted June 1, 2012 Author Share Posted June 1, 2012 I'm assuming you can already show a list of (accepted) friends so all you would need to add is an option to list declined friend requests Well, here is where maybe I didn't choose the best design... In a Member's Profile, the is a "My Friends" tab which shows all "accepted" Friends, but it is read-only. Then I have my "manage_requests.php" script that is supposed to just let a Member "Decide Later/Accept/Decline". Once a decision is made, I don't show "Declined" people thinking you would want to see that. I also don't have a way to UN-Friend people currently. Should I? Debbie Quote Link to comment https://forums.phpfreaks.com/topic/263470-show-2-values-in-query/#findComment-1350355 Share on other sites More sharing options...
Barand Posted June 1, 2012 Share Posted June 1, 2012 Toss a coin. Heads you should, tails you shouldn't :-) Quote Link to comment https://forums.phpfreaks.com/topic/263470-show-2-values-in-query/#findComment-1350362 Share on other sites More sharing options...
kicken Posted June 1, 2012 Share Posted June 1, 2012 Once a decision is made, I don't show "Declined" people thinking you would want to see that. I don't generally care who I decline. Most of the time it's just spammers or random people I don't care about that I decline so I couldn't care less if I ever saw there name again in some list saying who I declined. I also don't have a way to UN-Friend people currently. Should I? Yes, you probably should. Like most things in life friend statuses can change. You don't necessarily need a separate page for this, just a button next to them on the current friends list to remove them. Quote Link to comment https://forums.phpfreaks.com/topic/263470-show-2-values-in-query/#findComment-1350382 Share on other sites More sharing options...
doubledee Posted June 2, 2012 Author Share Posted June 2, 2012 Once a decision is made, I don't show "Declined" people thinking you would want to see that. I don't generally care who I decline. Most of the time it's just spammers or random people I don't care about that I decline so I couldn't care less if I ever saw there name again in some list saying who I declined. So you agree with me that when you click "Decline" that they should go *poof* for good, right? I also don't have a way to UN-Friend people currently. Should I? Yes, you probably should. Like most things in life friend statuses can change. You don't necessarily need a separate page for this, just a button next to them on the current friends list to remove them. Should my "manage_requests.php" page just be for NEW Friend-Requests? Or should I make it so New Requests appear as "Decide Later/Accept/Decline" and when you "Accept", the person stays in the list but is just marked as "Accepted", and then later if you want to "Decline" them you just click the other radio button? Also, you say you don't care about people you "Decline" but that then you say "Friendships change", so what about someone you "Declined" becoming your Friend later? Do I allow for that, and if so, how? Thanks, Debbie Quote Link to comment https://forums.phpfreaks.com/topic/263470-show-2-values-in-query/#findComment-1350444 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.