473,769 Members | 5,871 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Dynamic search with checkboxes

Hello everyone.

I'm having a problem with a search I want to make.

It's like this:

The user can choose about 15 checkboxes to be his search pattern.
According to the combination of checkboxes checked, I must do a
different query.

Is it really necessary to make 15 if...else statements and type in a
query for every combination the user may choose?

If anyone knows any easier way to do it, please help me.

Thanks.

Gustavo.

Oct 16 '06 #1
2 1746

GustavoBrust wrote:
Hello everyone.

I'm having a problem with a search I want to make.

It's like this:

The user can choose about 15 checkboxes to be his search pattern.
According to the combination of checkboxes checked, I must do a
different query.

Is it really necessary to make 15 if...else statements and type in a
query for every combination the user may choose?

If anyone knows any easier way to do it, please help me.

Thanks.

Gustavo.
You can post the checkboxes as one array from html, then in use foreach
with one if statement in it.
If you provide us the code it will be easier to determine ...
--------------------------------------------------------------------------
For php/ajax/javascript tutorials and tips, visit me on my blog at
http://www.nurazije.co.nr

Oct 16 '06 #2
In article <11************ **********@f16g 2000cwb.googleg roups.com>,
nu******@gmail. com says...
>
GustavoBrust wrote:
Hello everyone.

I'm having a problem with a search I want to make.

It's like this:

The user can choose about 15 checkboxes to be his search pattern.
According to the combination of checkboxes checked, I must do a
different query.

Is it really necessary to make 15 if...else statements and type in a
query for every combination the user may choose?

If anyone knows any easier way to do it, please help me.

Thanks.

Gustavo.
You can post the checkboxes as one array from html, then in use foreach
with one if statement in it.
If you provide us the code it will be easier to determine ...
--------------------------------------------------------------------------
For php/ajax/javascript tutorials and tips, visit me on my blog at
http://www.nurazije.co.nr

Depending on the type of query you're building, you might not even need
foreach() ... maybe something like this...

<body>
<form
action="<?php echo $_SERVER['PHP_SELF'] ?>"
method="post"
>
<input type="checkbox" name="id[]" value="1" /><br />
<input type="checkbox" name="id[]" value="2" /><br />
<input type="checkbox" name="id[]" value="3" /><br />
<input type="checkbox" name="id[]" value="4" /><br />
<input type="submit" />
</form>
<pre>
<?php
print_r($_POST) ;
if(isset($_POST['id']) {
$query =
"SELECT * FROM users WHERE id='" .
implode("' OR id='",$_POST['id']) .
"'" ;
}
// do your query processing
?>
</pre>
</body>

Of course you'd want to do a bit of validation first. And there are
other issues, for example, escaping single quotes, depending on whether
nor not Magic Quotes is enabled on your server.

Oct 21 '06 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

7
3729
by: Craig Storey | last post by:
I have a little php application to store day hiking trips and to keep a running total of their yearly trips for a few users. Currently they select their hiking routes using drop lists or checkboxes containing the names and numbers of the trails. If the route is simple the form takes 1-2 minutes to fill in, if it involves lots of tiny sections it can become tedious to search for every trailname and may take 20 minutes. Because of this...
1
1624
by: middletree | last post by:
Hate to post this in a separate post, but felt that the last thread was too far down to get noticed. It is called dynamic checkboxes, and it contained some good advice for me, but it led to another question, and I wanted to go ahead and post my question here in hopes of getting an answer. The advice given to me about having a number of checkboxes which are put onto the page from the database, was to name them all the same thing, and...
8
2833
by: DylanM | last post by:
I have some checkboxes that are generated from the results of a database search. At the moment, the checkboxes are part of a table making up a form. Users are going through the form, clicking the boxes and saving to the database at the end with the 'Submit' command button. Is it possible to save the changes as the checkboxes are clicked? I suppose I'd need to write some dynamic ASP event handling at the same time as creating the checkboxes......
2
2449
by: trank | last post by:
I created some checkboxes(<input type=checkbox>) dynamically,and then I'd like to access these checkboxes in code behind using C#. For they are not standard controls like Windows Checkbox, I can't catch it by FindControl().....how can i do this? Many thanks a lot! By trank trank@dynamic-x.net
3
3984
by: Leo J. Hart IV | last post by:
OK, here's another question for the experts: I am building a multi-step (3 steps actually) form using a panel for each step and hiding/displaying the appropriate panel/panels depending on which step you're on. This all works fine, but I ran into some trouble when I started creating controls dynamically in my code-behind file. Each panel contains a table which is filled with various radio buttons, text fields and the such which are...
3
5773
by: Jack Black | last post by:
Using VS.Net 2k3 to build ASP.Net app with VB code-behind pages... Hi, all! I've been struggling with getting a dynamically-generated CheckBoxList generated. I've finally been able to get the list generated, but now there are two problems I haven't been able to overcome: 1) ASP.Net is munging the checkbox ID/Names of the checkboxes: I give it a name like "myCheckbox" and asp.net is creating the checkboxes with the name...
2
7053
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...
0
1518
by: TarekSaad | last post by:
I am using VB2005 and have created a dynamic list of checkboxes and depending on which file the user selects there may be between 1 and 20 checkboxed that appear in a form. The user then checks any number of these checkboxes. I know how many checkboxes exist. I want to scroll down through the check boxes, one after the other and depending on if they are checked or not I different things need to happen. How do I select checkbox 1,...
2
4893
by: scottSD | last post by:
Hi everyone. this is my first post here, but i've found quite a bit of great information from reading the forums in the past. i'm not sure if what i'm trying to do is possible or not, but here it is: i'm creating a dynamic list of checkboxes, basically to allow access to client information on a user by user basis. i use ajax to bring back a full list of clients, then loop through the list and create a checkbox for each client to...
0
9589
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
9863
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
8872
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
7409
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
6673
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
5299
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...
1
3959
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
2
3562
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2815
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.