Jump to content

Recommended Posts

I have:

$sql=mysql_query("SELECT * FROM report WHERE (`verdict` = '') AND (`staff1` = '') OR (`staff2` = '') OR (`staff3` = '') AND (`staff1` != 'Adminben')  ORDER BY `dtreported` ASC");

And BTW satff1 is = Adminben and yet it still selects and show it!!!

Does anyone have any idea why this is i have tried also using a variable in their so as to automate it but to the same result.

Many thanks in advance.

 

the logic makes sense, but i "think" you mean todo this

$sql=mysql_query("SELECT * FROM report WHERE (`verdict` = '') AND ((`staff1` = '') OR (`staff2` = '') OR (`staff3` = '')) AND (`staff1` != 'Adminben') ORDER BY `dtreported` ASC");

yes, your OR's and AND's are confused. MySQL takes the quickest literal way out. you'll need to wrap up some conditions. The ONLY conditions that have to be met to match this statement is if staff2 = '' OR staff3 = ''. That's probably what you're getting; all cases where staff2 = '' OR staff3 = ''

 

$sql=mysql_query("SELECT * FROM report WHERE (`verdict` = '') AND (`staff1` = '') OR (`staff2` = '') OR (`staff3` = '') AND (`staff1` != 'Adminben')  ORDER BY `dtreported` ASC");

 

$sql=mysql_query("SELECT * FROM report WHERE (`verdict` = '') AND ((`staff1` = '') OR (`staff2` = '') OR (`staff3` = '')) AND (`staff1` != 'Adminben') ORDER BY `dtreported` ASC");

WORKS however

$sql=mysql_query("SELECT * FROM report WHERE (`verdict` = '') AND ((`staff1` = '') OR (`staff2` = '') OR (`staff3` = '')) AND ((`staff1` != 'Adminben') OR (`staff2` !='Adminben')) ORDER BY `dtreported` ASC");

DOESNT.

 

Again Both staff1 and staff2 are set but when i check just staff1 it works but as soon as i try that staff2 using the  ( ) Double bracket method it breaks and just shows all of them even if if staff1 != Adminben.

 

Sorry to ask AGAIN but please does any one know why this is happening???

 

Many thanks in advance!

can you describe what your trying to get..

as your logic is wrong, so without know what you want is very hard to correct..!

 

a bit of a shot in the dark.. but

i think your searching for records where

verdict is empty, and staff1, 2 or 3 are empty

BUT Staff1 or 2  are set to Adminben,

 

so if staff1 is empty but staff2 is Adminben then ignore it..

 

something like

$sql=mysql_query("
SELECT * FROM report WHERE `verdict` = '' AND (`staff1` = '' OR `staff2` = '' OR staff3` = '') AND NOT (`staff1` = 'Adminben' OR `staff2` ='Adminben') ORDER BY `dtreported` ASC");

a bit of a shot in the dark.. but

i think your searching for records where

verdict is empty, and staff1, 2 or 3 are empty

BUT Staff1 or 2  are set to Adminben,

 

Almost right but where satff 1 or 2 is NOT set to adminben/the players name.

i think this may work..

$sql=mysql_query("
SELECT * FROM report WHERE `verdict` = '' AND (`staff1` = '' OR `staff2` = '' OR staff3` = '') AND NOT (`staff1` = 'Adminben' OR `staff2` ='Adminben') ORDER BY `dtreported` ASC");

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.