Jump to content

Proper syntax "elseif"


adman4054

Recommended Posts

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

Link to comment
https://forums.phpfreaks.com/topic/291304-proper-syntax-elseif/
Share on other sites

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!

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.