473,398 Members | 2,525 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,398 software developers and data experts.

multiple - linked dynamic combo boxes from sql

13
Hi, noob in need of assistance..

i want to be able to create three combo boxes that are filled dynamically from my tables but each selection box to be "restrained" by the value fo the previous selection.

for examble
combo1 Categories (display all my categories)ok
combo2 Subcategory( display only subcategories of the previous selected category)
combo3 Subsubcategory2(display only subcategories of the previous selected subcategory)

wha i ve done up to now is to greate queries that get my desired vales from my tables but i dont know hoe to restrict those queries dynamically based on the second and third combo box selections


After connecting to my db i use the followinf to create my queries:
Expand|Select|Wrap|Line Numbers
  1. <?php
  2. $query = "SELECT mycategories FROM Categories";
  3. $query2="SELECT mysubcategories FROM Subcategories";
  4.  
  5. $result = mysql_query($query) or die(mysql_error());
  6. $result2 = mysql_query($query2) or die(mysql_error());
  7.  
  8.  
and whwere i want the combobox to appear i use the follwong to create and populate them

Expand|Select|Wrap|Line Numbers
  1. <?php 
  2. $dropdown = "<select name='category'>";
  3.  
  4. while($row = mysql_fetch_assoc($result)) {
  5.  
  6.   $dropdown .= "\r\n<option value='{$row
  7.  
  8. ['category']}'>{$row['category']}</option>";
  9.  
  10. }
  11.  
  12. $dropdown .= "\r\n</select>";
  13.  
  14. echo $dropdown;
  15.  
  16. $dropdown2 = "<select name='Subcategory'>";
  17.  
  18. while($row = mysql_fetch_assoc($result2)) {
  19.  
  20.   $dropdown2 .= "\r\n<option value='{$row
  21.  
  22. ['subcategory']}'>{$row['subcategory']}</option>";
  23.  
  24.  
  25. }
  26.  
  27. $dropdown2 .= "\r\n</select>";
  28.  
  29. echo $dropdown2;
  30. ?>
i tried saving $dropdown on a variable in order to use it as a condition in my 2nd and 3rd query( where subcategory_parent=category) but with no luck



any tips how to do this????
Jul 29 '13 #1
0 1223

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

Similar topics

13
by: mr_burns | last post by:
hi, is it possible to change the contents of a combo box when the contents of another are changed. for example, if i had a combo box called garments containing shirts, trousers and hats, when...
0
by: Duncan Spence | last post by:
Hi all, I'm sure I'm doing something silly here, but can't see it! I'm creating a series of combo boxes on a Windows Form in VB.NET. The lists of all of the comboboxes are identical and are...
3
by: vgrssrtrs | last post by:
<html> <head> <script language="JavaScript"> <!-- /* *** Multiple dynamic combo boxes *** by Mirko Elviro, 9 Mar 2005 *** ***Please do not remove this comment
0
by: Andrew | last post by:
Hello, I am trying to create a chart whose underlying query is linked to 2 combo boxes on the same form. I want to pass the values from the combo boxes into the chart query to allow the chart...
2
by: taras.di | last post by:
Hi everyone, I've been reading up on how to create a drop down box who's context is dynamically produced based on the value of a previous select box. I've read a lot about some of the browsers...
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...
0
by: arsenal69 | last post by:
Hi to all... last time i gave an incomplete description of the real problem.. even though i got help.. and i am very thankful for that any ways heres what i really need help on 2 combo boxes.......
6
by: Dave | last post by:
I want to put the information that the user selects in my combo boxes into a subform that lies on the same form as the combo boxes. Thanks for your help already, Dave
1
by: bkholloway | last post by:
hello...first time here...have an access 07 db and need to have multiple dependent combo boxes. I have a little experience using expression builder but not VBA...basically need to limit choices in...
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...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
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
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
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
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
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.