I am sending some files from AJAX to a PHP file. Anyway, this is about filter options, I am sending it like this:
filter [0] [data] [type] string filter [0] [data] [value] automobile Filter [0] [field] product filter [1] [data] [type] numeric filter [1] [data] [value] 6000 filter [1] [field] value
Above is taken from the FireBug console, then in PHP:
$ filter = $ _POST ['Filter'. $ I]; If (is_array ($ filter)) {for ($ i = 0; $ i & lt; count ($ filter); $ i ++) {switch ($ filter [$ i] ['data'] ['type' ]] {Case 'string': // I am selecting mine from database based on it and by doing so
Therefore, its translation will be: "I get all the records from the database : Hmm, let's check the filter ... I'm getting the filter type witch for the first time "String" requires the witch to be applied on the MySQL column called "Product" ... so I can say "Autom Searching for the value of "eBay" ... but I have not finished yet, the second filter refers to a numerical filter for the column "value" from the database, so I'm assuming it and adding it to the query I will select all the automobiles whose price is more than 6000.
So far it is so good. The problem is that my method of getting the data has changed and I do not send my data. This format is no longer in this format. The new format is a URL witch, looks like:
filter [0] [field] = prodc T & amp; [0] [data] [type] = filter & string; To filter [1] [area] = price & amp ;; [0] [data] [value] = filter the automobile & filter [1] [data] [type] numerical & amp; Filters [1] [Data] [value] = 6000
I have a "& amp; I can make a blast and finish it with an array ... I can do a lot ... The problem is that I do not know that building my query to work with such obtained data How to adjust the script. So, "switch ($ filter [$ i] ['data'] ['type']) {" then ...
code to modify any idea?
Thank you!
($ queryString); And then do everything in general, this method will act on the query string and import the variable for the global name space (which can be dangerous), so perhaps use the second form (listed on the manual page):
$ result = array (); Parse_str ($ queryString, $ result) $ filter = $ result ['filter']; Foreign Currency ($ filter as $ filter) {// your code}
Comments
Post a Comment