fife Posted November 4, 2011 Share Posted November 4, 2011 I have a div I want to show but I want to show it if any of the results from a certain part of my query = 1. Here is my code <?php if($country['sightseeing']=='1') || if($country['nightlife']=='1') || if($country['hightlights']=='1') || if($country['tips']=='1') || if($country['events']=='1') || if($country['news']=='1') || if($country['contrasts']=='1') || if($country['lifestyle']=='1') || if($country['food']=='1') || if($country['food']=='1') { //do something } ?> Now I know my sytax here is incorrect but I dont know who you write this any other way. Can somebody please help me. Thanks Quote Link to comment https://forums.phpfreaks.com/topic/250432-if-statement-with-ors-involved/ Share on other sites More sharing options...
requinix Posted November 4, 2011 Share Posted November 4, 2011 The if is a construct. You give it a condition, which could be a bunch of conditions ||d together. if($country['sightseeing']=='1' || $country['nightlife']=='1' || $country['hightlights']=='1' ...) But it sounds like you simply want to know if there's a 1 anywhere in the $country array? if(in_array('1', $country)) Quote Link to comment https://forums.phpfreaks.com/topic/250432-if-statement-with-ors-involved/#findComment-1284890 Share on other sites More sharing options...
fife Posted November 4, 2011 Author Share Posted November 4, 2011 yes thankyou the second solution there is perfect. Quote Link to comment https://forums.phpfreaks.com/topic/250432-if-statement-with-ors-involved/#findComment-1284892 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.