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

dynamic populated dropdown from mysql database

hi,
i m newbie php+mysql. in i have the following problem. i tried my best to solve it but could do it. please help me.

i have a from where 3 fields are STATE, AREA and SUBRUB. AREA is connected with STATE and SUBRUB is connected with AREA. when a person will select a STATE the corresponding AREA will be available in dropdown box. and when a AREA is selected the corresponding SUBRUB will be available in a dropdown box. please help me with the solution.

best regards,
Mainul
Sep 15 '09 #1
4 2787
TheServant
1,168 Expert 1GB
I am guessing that you are not submitting the form between changing STATE, AREA and SUBURB... if you are, you shouldn't.

That is a javascript/AJAX task, as once the page is on your screen, PHP is finished. Look here or just search in Google for the difference between Client side and Server side.
Sep 15 '09 #2
prabirchoudhury
162 100+
ok here is the sudo code

1.
Expand|Select|Wrap|Line Numbers
  1. $query1=mysql_query("SELECT DISTINCT AREA ,AREA _id FROM AREA  where STATE_ID = $ID");
  2.  
  3.  
  4.   dropdown1 <select name=dd1> <option value=''>Select Area</option>
  5.     <?php
  6.  
  7.       while($row1= mysql_fetch_array($query1)) {
  8.        echo "<option value='$row1[AREA _id]'>$row1[AREA]</option>";
  9.  
  10.       $query2=mysql_query("SELECT DISTINCT SUBRUB,SUBRUB_id FROM SUBRUB where SUBRUB_id = $row1[[AREA _id]");
  11.  
  12.       // dropdown 2
  13.      echo "<select name=dd2> <option value=''> select SUBRUB ..</option>";
  14.     while($row2= mysql_fetch_array($query2)) {
  15.        echo "<option value='$row2[SUBRUB_id]'>$row1[SUBRUB]</option>";
  16.  
  17.     } // end of second while
  18.  
  19.    echo </select>
  20.  
  21.    }  // end of first while
  22.  
  23. echo "<select>"
  24.  
could have a look on here
basic tutorial

:))
Sep 16 '09 #3
TheServant
1,168 Expert 1GB
prabirchoudhury, that will only display a static dropdown list? Unless I have missed something. But mainul05, if you combine prabirchoudhury's script with a little javascript or AJAX, and you will have your solution.
Sep 16 '09 #4
prabirchoudhury
162 100+
Y you are right
that javascript part he should get the tutorial link i have added. TheServant ,thanks for your mention.

:))
Sep 16 '09 #5

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

Similar topics

2
by: Harry Simpson | last post by:
Basically have a datalist now with an itemtemplate containing a textbox for user entry and a label. The datalist is bound to a database table. My boss wants the database table to have possible...
1
by: russ | last post by:
Hi all, Here's a problem I'm having with a dynamic table. Following the guidelines here (http://www.codeproject.com/aspnet/dynamiccontrols.asp), which make perfect sense. The problem is that...
7
by: Jeff Uchtman | last post by:
I know I have done this but my mind is fried. I have a dynamic dropdown in a form. I need to pull both the dynamic dropdown's ID and name listed in the dropdown. Need a little help with grey...
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,...
9
by: Tarscher | last post by:
hi all, I have this seemingly simple problem. I have lost a lot of time on it though. When a user selects a value from a dropdownlist (static control) a dynamic control is generated. I have...
4
by: Panna | last post by:
Hey there I am using phpMyAdmin and MySQL to develop a dbase application. I have a dropdown menu on one of the pages which gets populated automatically with data from a table in the database....
3
by: d1156676 | last post by:
Hi I have a Dynamic dropdown reading in data from a MySql database, I need to refresh the dropdown when the database is updated without refreshing the whole page. I have had a go at trying to...
0
by: pansell | last post by:
Hi, I have a dropdown list that is populated with table names from my database using SqlDataSource1. When I change the selected index I can get the table name back from the dropdown and display...
4
by: d0353101 | last post by:
Hi, I am having 2 dropdowns on my page. The values in both the drop downs have to be populated through DataBase. Problem : I dont know how to populate the second Dropdown automatically if...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 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 former...

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.