Jump to content

If posted values equal array


rvdb86

Recommended Posts

Hi, I am trying to make a search function, and I am not 100% sure how to match the posted values from the search form to the array.

I should mention that idea is to search a database of apartments based on different aspects of each apartment, such as their type, the area they are in, appliances that are included in the apartment etc.

 

The form has a few options, but none of them are mandatory.

 

The form fields are:

  • Type: Select, Name: Type
  • Type: Select, Name: Area
  • Type: Check boxes, Name: Appliances
  • Type: Check boxes, Name: Amenities

 

here is an example of the array of an apartment:

[apartmentId] => 27
            [Area] => 6
            [Appliances] => Array
                (
                    [0] => 1
                    [1] => 5
                )

            [Amenities] => Array
                (
                    [0] => 1
                    [1] => 2
                )

            [TypeId] => 9

 

The values of the array are the id's for each item, so in the array example above the area Id is 6 and it has the amenities with the id's 1 and 2

 

I need a way to check if elements match only if they have been inputed in the form, and a way to loop through the arrays and print only the apartments that match the posted variables submitted from the search form.

 

Thanks for any suggestions or just taking the time to read this!

Link to comment
https://forums.phpfreaks.com/topic/180907-if-posted-values-equal-array/
Share on other sites

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.