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 Link to comment https://forums.phpfreaks.com/topic/92628-help-creating-if-with-2-or-more-conditions/ 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 Link to comment https://forums.phpfreaks.com/topic/92628-help-creating-if-with-2-or-more-conditions/#findComment-474750 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? Link to comment https://forums.phpfreaks.com/topic/92628-help-creating-if-with-2-or-more-conditions/#findComment-474759 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' ? Link to comment https://forums.phpfreaks.com/topic/92628-help-creating-if-with-2-or-more-conditions/#findComment-474762 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']) ?> Link to comment https://forums.phpfreaks.com/topic/92628-help-creating-if-with-2-or-more-conditions/#findComment-474788 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 Link to comment https://forums.phpfreaks.com/topic/92628-help-creating-if-with-2-or-more-conditions/#findComment-474795 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. Link to comment https://forums.phpfreaks.com/topic/92628-help-creating-if-with-2-or-more-conditions/#findComment-474800 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.