czs Posted February 23, 2008 Share Posted February 23, 2008 Hi all I'm trying to make an if condition based off more than one criteria. Here is the code I have now but it doesn't work. My guess is the word AND isn't the right way to do this. if ($row_rsM1p['Match1'] !== '0' AND $row_rsM1p['Match2'] !== '0' AND $row_rsM1p['Match3'] == '0') { //do stuff } Thanks Quote Link to comment Share on other sites More sharing options...
Sulman Posted February 23, 2008 Share Posted February 23, 2008 Try this: <?php if ($row_rsM1p['Match1'] != '0' AND $row_rsM1p['Match2'] != '0' AND $row_rsM1p['Match3'] == '0') { //do stuff } ?> Too many equals signs Quote Link to comment Share on other sites More sharing options...
czs Posted February 23, 2008 Author Share Posted February 23, 2008 Thank you for helping but that didn't work. I think there might be a fundamental problem with my if statement. I want it to do the stuff within the statement if the field "Match1" in the recordset "rsM1p" contains just the number 0 . Is writing == '0' the way I did, the right way to do this? Quote Link to comment Share on other sites More sharing options...
czs Posted February 23, 2008 Author Share Posted February 23, 2008 Update: I replaced '0' with a hidden field name that I create 'Post0' with a value of 0 and it still didn't work. Now I'm starting to think that the way I'm referencing the field in the recordset is wrong. Is <?php if ($row_rsM1p['Match1'] != 'Post0') ?> the right way to say if field match1 in recordset rsM1p does not equal the value in the hidden field 'Post0' ? Quote Link to comment Share on other sites More sharing options...
Sulman Posted February 23, 2008 Share Posted February 23, 2008 not quite. It should be: <?php if ($row_rsM1p['Match1'] != $_POST['Post0']) ?> Quote Link to comment Share on other sites More sharing options...
Jessica Posted February 23, 2008 Share Posted February 23, 2008 PS: AND vs &&: The reason for the two different variations of "and" and "or" operators is that they operate at different precedences. (See Operator Precedence.) http://www.php.net/manual/sl/language.operators.logical.php Quote Link to comment Share on other sites More sharing options...
czs Posted February 23, 2008 Author Share Posted February 23, 2008 Thanks everyone for your help. I have figured it out. Thanks. Quote Link to comment 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.