473,812 Members | 2,984 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Usings Arrays & Multiple Filters

1 New Member
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?modul e=Pagesetter&fi lter1=meat1:lik e:1&filter2=mea t2: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 2129
pbmods
5,821 Recognized Expert Expert
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
1698
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 records in each of these, not just the ones i have showing based on the filters set. These filters are set in the VB code, as child/master dependencies wouldn't cut it in this case. I'm sort of pressed on time here, so I really don't want to...
2
7055
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, input box for units of service, description of the service and each row has its own dropdown list of unit fees that apply. Each dynamically created row will return 3 values fee1_choice, fee1_unit and fee1_money. Note The above informaton is...
2
2826
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 this query from multiple forms because each report needs different filters on this query. Is there a way to to this like having multiple copies of this query keeping the name same, like an alias name? I would appreciate ideas on this. Thanks! ...
1
4771
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 Subform/Subreport and then be able to print a report. For example Filter1, list the company name. Filter2 list the options (open, close). Filter3 is related to the company acct balance, the options are (<$1000, >$1000, >$5000). I would like to be...
1
6445
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 past due demand fax and my combo boxes work fine opid prodcd
4
1535
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 and I don't have the skills to change it quickly, and it only outputs in a structured way... so I am not able to go dig into the code of the out-of-box program and solve it. This it the first time I've really dug into JS. My JS knowledge is very...
4
1449
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 special dish name <dt>, second to write the daily dish description <dd>. DishName works, just can't figure out the description. The <body> code was provided, I only need to get (and understand) the two arrays and two document.write scripts working. I've...
1
4229
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 aligned to the top, along with the slideshow and link buttons, you have to scroll down to see the text - how can I make IE6 display correctly? http://geekarama.co.uk/new_home.html here is the code for new_home.html and following that the CSS...
4
2870
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 formats the filter checks? So far it's evading me. The Manual and w3schools just send me in
0
9734
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
10664
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
1
10417
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
9219
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, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
7677
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 presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6897
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5568
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
5704
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4357
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system

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.