User Name Password Register
DaniWeb IT Discussion Community
All
What is DaniWeb IT Discussion Community?
You're currently browsing the PHP section within the Web Development category of DaniWeb, a massive community of 375,215 software developers, web developers, Internet marketers, and tech gurus who are all enthusiastic about making contacts, networking, and learning from each other. In fact, there are 2,313 IT professionals currently interacting right now! Registration is free, only takes a minute and lets you enjoy all of the interactive features of the site.
Please support our PHP advertiser: Lunarpages PHP Web Hosting
Views: 275 | Replies: 4
Reply
Join Date: Dec 2007
Posts: 5
Reputation: sanch3za is an unknown quantity at this point 
Rep Power: 0
Solved Threads: 0
sanch3za sanch3za is offline Offline
Newbie Poster

dynamic query

  #1  
May 13th, 2008
for example :
I have 4 check box with their own variables a,b,c,d
How can I create query with condition using what users choose,
where users can choose more than one check box

thanks for your support
AddThis Social Bookmark Button
Reply With Quote  
Join Date: Nov 2007
Location: Arkansas
Posts: 259
Reputation: buddylee17 is on a distinguished road 
Rep Power: 1
Solved Threads: 45
buddylee17's Avatar
buddylee17 buddylee17 is offline Offline
Posting Whiz in Training

Re: dynamic query

  #2  
May 13th, 2008
What type of query (SELECT, UPDATE, INSERT...). Also, can you provide the html for the checkboxes?
Reply With Quote  
Join Date: May 2008
Posts: 2
Reputation: RupertA is an unknown quantity at this point 
Rep Power: 0
Solved Threads: 0
RupertA RupertA is offline Offline
Newbie Poster

Re: dynamic query

  #3  
May 13th, 2008
maybe something like:
"select.....blah blah....where a = $_POST['checkboxarrayname']['a'] and b = $_POST['checkboxarrayname']['b']"
and the html is:
<input type='checkbox' name='checkboxarrayname[a]' value='1'>

basically using posting array variables
HTH
Reply With Quote  
Join Date: Dec 2007
Posts: 5
Reputation: sanch3za is an unknown quantity at this point 
Rep Power: 0
Solved Threads: 0
sanch3za sanch3za is offline Offline
Newbie Poster

Re: dynamic query

  #4  
May 16th, 2008
the problem is we don't know which checkbox is checked and count how many checkbox is checked, example we know 2 checkbox is checked so the query is two condition. if three checkbox is checked so the query is three condition.
can I make a query with a dinamic condition according how many checkbox is checked?
Reply With Quote  
Join Date: Nov 2007
Location: Bangalore, India
Posts: 3,057
Reputation: nav33n has a spectacular aura about nav33n has a spectacular aura about 
Rep Power: 8
Solved Threads: 229
nav33n's Avatar
nav33n nav33n is offline Offline
Posting Sensei

Re: dynamic query

  #5  
May 16th, 2008
When you submit the page, only those checkboxes which were checked will be submitted. So, you will have the count of checkboxes which are checked, you will have all the checkboxes which were checked. Build your query depending upon those values.
Programming today is a race between software engineers striving to build bigger and better idiot-proof programs, and the Universe trying to produce bigger and better idiots. So far, the Universe is winning.

*PM asking for help will be ignored*
Reply With Quote  
Reply

Only community members can participate in forum threads. You must register or log in to contribute.

Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)

 

DaniWeb PHP Marketplace
Thread Tools Display Modes

Similar Threads
Other Threads in the PHP Forum

All times are GMT -4. The time now is 3:11 am.
Forum system based on vBulletin Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
©2003 - 2008 DaniWeb® LLC