Hi people.
Its sticky-time again for me.
I have a form which will serve as a search for products.
The form is generated dynamically from data from the database. Each item has a checkbox and at the bottom is a radio for ALL or ANY.
The form is broken down into sections.
To illustrate what I mean before I get to the question, let us assume the products in question were Lego blocks as we all know what they are.
The form would be broken down thus:
All blocks Self explanitory
All [colour] blocks Generated from DB, listing a newcheckbox and title for each colour found (ie ‘All red blocks[] All blue blocks[]’ etc)
All [size] blocks As above, generated from DB, listing a newcheckbox and title for each colour found (ie ‘All 2x2 blocks[] All 2x4 blocks[]’ etc)
Submit button
If the user wanted to search for all blue 2x2 blocks they would check ‘All blue’ and ‘All 2x2’ and hit Submit.
The plan is on the next page it would list all blue 2x2 blocks in the db by creating a query based on the checkboxes.
I have tried having the different sections (colours, size etc) as arrays
<input name=colour type=checkbox value=blue />
and I have tried as seperate entities
<input name=colour type=checkbox value=$colour />
I have to admit I do have problems with arrays. I understand what they are but my brain goes funny when I try and retrieve stuff from them non-manually.
Anyway I need to process the form by checking which boxes are checked and from which section then create a query such as [COLOR=blue]select all from legoblocks [COLOR=royalblue][(if checkboxes other than ALL checked)[/COLOR]where[COLOR=royalblue]] [(if checked)[/COLOR]colour=x[COLOR=royalblue]] [(if more than one section with a checked box)[/COLOR]AND[COLOR=royalblue](or OR depending on radiobox)] [(if exists)[/COLOR]size=y[COLOR=royalblue]][/COLOR] AND etc[/COLOR]
Yes I know that isn’t a proper sql query
Anyone any pointers? I have tried various combinations of whiles, counters, foreach’s and ifs. Maybe it my manflu twisting my head, maybe it is my poor knowledge of php. Who knows, but I am flailing wildly.