473,405 Members | 2,261 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,405 software developers and data experts.

Usings Arrays & Multiple Filters

I'm currently working on a website for recipes that allows users to search by ingredients they have and I'm experiencing a problem with my filtering. My site allows users to just check the checkboxes of ingredients they have. I've been in and out of every forum I can find on the internet any solution and this forum has been pretty helpful! I'm using PostNuke for my CMS & the bulk of my program is run through Pagesetter. I can get my simple commands to work but when I add multiple ingredients to my search I can't get it to filter all the categories. I have my recipes broken down in 6 different categories that go into my db, eg meats1, meats2, fruits1, fruits2 etc. Sample of the code:
Expand|Select|Wrap|Line Numbers
  1.           <input type="checkbox" name="food[]" value="6">Pork<br>
  2.      <input type="checkbox" name="food[]" value="163">Ground Beef<br>
  3.     <input type="checkbox" name="food[]" value="164">Deer Beef<br>
  4.     <input type="checkbox" name="food[]" value="165">Meat Balls<br>
  5.     <input type="checkbox" name="food[]" value="166">Roast Beef<br>
  6.  
Each ingredient is stored as a number that the pagesetter module determines. I have figured out that 1-20 & 40-26 are meats and so on but can't figure out how to apply it to php to run if statements & to change $cata below for the db field that the ingredient is in, but will only be that field once per search:
Expand|Select|Wrap|Line Numbers
  1. <input type="hidden" name="filter1"
  2.         value="$cata[]:like:$food[]" />
  3.  
  4. <input type="submit" value="Update">
The filter 1 would also need to be changed per ingredient clicked, filter2, filter3. The module pagesetter itself will use long urls to relay the info:

http://www.clickncook.com/PostNuke/index.php?module=Pagesetter&filter1=meat1:like:1&f ilter2=meat2:like:2

I've been banging my head on my desk for the past month trying to figure out what I'm doing wrong, and what I need to do to correct it. Example of it can be seen at :

http://www.clickncook.com/PostNuke/i...ule=Pagesetter

Sorry for the long first time post but any help, or steering in a direction is greatly appreciated.

Martin Curry
Jul 26 '07 #1
1 2106
pbmods
5,821 Expert 4TB
Heya, Martin. Welcome to TSDN!

Let me see if I understand what you're trying to accomplish here.

So you have a bunch of categories (Meats, Breads, etc.), and within each category are a bunch of subcategories (Hamburger Patty's [sic], Steak, etc.).

The User can check as many boxes as he wants, including from multiple categories, and you want to list the results like this:

For any MEAT checkboxes, only return results in the MEAT category that match the selected subcategories. For any BREAD checkboxes that were selected, only return results in the BREAD category that match the selected subcategories. And so on.

How am I doing so far?

The solution is actually not that bad, and it's pretty close to what you have so far:

Expand|Select|Wrap|Line Numbers
  1. <input ... name="food[{categoryID}][]" value="{subcategoryID}" />
  2.  
When the User submits the form, you'll have a $_POST array that looks something like this:

Expand|Select|Wrap|Line Numbers
  1. $_POST = array(
  2.     'food'    =>    array(
  3.         '1'        =>    array(
  4.             '12'    =>    'ON',
  5.             '18'    =>    'ON'
  6.         ),
  7.  
  8.         '5'        =>    array(
  9.             '48'    =>    'ON'
  10.         )
  11.     ),
  12.     .
  13.     .
  14.     .
  15. );
  16.  
Or something like that. And of course, using nested foreach loops, you can quickly build the sql query or whatever it is you need to do with this information.
Jul 26 '07 #2

Sign in to post your reply or Sign up for a free account.

Similar topics

1
by: tremor | last post by:
I'd like to print a form based on the filters currently applied to it (these are again based on selections in combo-boxes). The form has multiple subforms, and as I try to print it, it prints all...
2
by: assgar | last post by:
Hi Developemnt on win2003 server. Final server will be linux Apache,Mysql and PHP is being used. I use 2 scripts(form and process). The form displays multiple dynamic rows with chechboxs,...
2
by: yxktmp | last post by:
Hi; I have a main starting query for most of my reporting. I branch out from this query to other queries. This main query contains multiple form control filters (query criterias) . I want to use...
1
by: JC21 | last post by:
Hi guys, I was wondering if someone could give me some insight on this. On a form I would like to have 3 combo boxes which can be used as filters. I would like the information to be displayed on a...
1
by: favor08 | last post by:
I need help with a big project. I am struggle getting multiple option buttons and filters to work together. They need to be able to filter a subform. My first set of option buttons work fine all...
4
by: STIAdmin | last post by:
Happy Holidays to all of you! This is my first time posting. I'm working on a web project and trying to get this done before Christmas. The limitation is that I'm using an out of the box program...
4
by: pmactdot | last post by:
Hi, I'm looking for some assistance on a case study...I have two arrays <head>: one for daily special dish name, second for the daily dish description, then I have two document.write: a daily...
1
by: littlealex | last post by:
IE6 not displaying text correctly - IE 7 & Firefox 3 are fine! Need some help with this as fairly new to CSS! In IE6 the text for the following page doesn't display properly - rather than being...
4
by: Twayne | last post by:
Hi, I've been playing with ' if(!filter_var($email, FILTER_VALIDATE_EMAIL)) ' on my server and it seems to be working 100%. Pretty handy. Any ideas where I could find a summary of the e-mail...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.