adman4054 Posted September 26, 2014 Share Posted September 26, 2014 That's right I'm pretty green when it comes to PHP. I googled it, but it looks like there are several ways to achieve this, wondering which is best. elseif ($subcategory_id == 400) I want the code to include a number of subcategory_ids, 400, 450, 500, 760, etc. There isn't a range, so what would be the proper way to include multiple category_ids. Thank you Quote Link to comment https://forums.phpfreaks.com/topic/291304-proper-syntax-elseif/ Share on other sites More sharing options...
requinix Posted September 26, 2014 Share Posted September 26, 2014 I'd use in_array. elseif (in_array($subcategory_id, array(400, 450, 500, 760)))There are cleverer tactics though, depending on the rest of your code... Quote Link to comment https://forums.phpfreaks.com/topic/291304-proper-syntax-elseif/#findComment-1492175 Share on other sites More sharing options...
adman4054 Posted September 26, 2014 Author Share Posted September 26, 2014 Thank you requinx for the quick reply. I can use the "in array" in your above code with this: elseif ($subcategory_id == 400) { $this->db->where('number >=', 24); $this->db->where('number <=', 27); $query = $this->db->get('package'); if ($query->num_rows() > 0) { foreach ($query->result() as $row) { $data[] = $row; } return $data; } return array(); Thanks again! Quote Link to comment https://forums.phpfreaks.com/topic/291304-proper-syntax-elseif/#findComment-1492177 Share on other sites More sharing options...
cyberRobot Posted September 26, 2014 Share Posted September 26, 2014 Thank you requinx for the quick reply. I can use the "in array" in your above code with this: Possibly...what's supposed to happen when $subcategory_id is 450, 500, etc.? Quote Link to comment https://forums.phpfreaks.com/topic/291304-proper-syntax-elseif/#findComment-1492195 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.