friends system help?
I have a partly working friends system, but one of my MySQL queries only selects the whole table variable and I want it to select individual parts of the table variable.
The purpose of this is to count how many times the users name occurs in the the whole table in general. This is my query:
SELECT Reciver, Sender
FROM Friends
WHERE (Reciver or Sender) = '%$fullname%'
AND accepted = 2
The $fullname
is a variable with the users name in it.
In the table Friends I have:
id Sender Reciver accepted
1 bob fred 2
1 fred jim 1
This is what my table loo开发者_JS百科ks like and for accepted = 2
they have accepted and 1
is they are waiting.
Question: Can you look at all my coding I have shown here and see if their is another way (easier way) or how to fix it?
Thanks in advance.
Your where may need to be updated. Try WHERE (Reciver = '%$fullname%' or Sender = '%$fullname%') AND accepted = 2
The following will count how often the desired user appears in the database table:
SELECT COUNT(*)
WHERE (Reciver = '%$fullname%' or Sender = '%$fullname%')
AND accepted = 2
Daniel Moniz
精彩评论