breadnbutter Posted April 29, 2006 Share Posted April 29, 2006 I'm pretty new to PHP. I have done a few pages of code, and I'm now starting to get my head round it. However, I've looked on php.net and can't find the right syntax for an 'AND' or and 'OR' statement, a bit like in SQL. Is there such a thing?Here is the context I want to use it in.$areab = ($_POST['county']); if ($areab == "Cambridgeshire") {echo "E Anglia";} else {echo "";}This is going to be part of a much more complex bit of code, but |I am using the echo to test to see if this state ment works. Which is does. But what I want to do is$areab = ($_POST['county']); if ($areab == ("Cambridgeshire") OR ("Suffolk") OR ("Norfolk") {echo "E Anglia";} else {echo "";}but this doesn't work, what is it that I should be doing? Link to comment https://forums.phpfreaks.com/topic/8713-andor/ Share on other sites More sharing options...
breadnbutter Posted April 29, 2006 Author Share Posted April 29, 2006 Sorted it by setting up an array.... Link to comment https://forums.phpfreaks.com/topic/8713-andor/#findComment-31984 Share on other sites More sharing options...
.josh Posted April 29, 2006 Share Posted April 29, 2006 well just for future reference, it would look like this: if (($areab == "Cambridgeshire" OR ($areab=="Suffolk") OR ($areab=="Norfolk")){echo "E Anglia";} else {echo "";}you can also use || instead of OR Link to comment https://forums.phpfreaks.com/topic/8713-andor/#findComment-31992 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.