473,396 Members | 1,712 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,396 software developers and data experts.

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 1731

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**********************@f16g2000cwb.googlegroups .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
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...
1
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...
8
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...
2
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...
3
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...
3
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...
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,...
0
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...
2
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...
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: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
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
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...
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,...

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.