473,666 Members | 2,039 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Double drop down menue

250 Contributor
I want to use two drop down menus in my php application. All data should select from the database(Mysql) . Eg: 1st drop down(Fruit,Coun try,game) after selecting a item from the first drop down , second one should load perticular data from tha database. If i select Fruit then automatically load Mango,banana.et c to the second drop down. Could you please help me?
Mar 25 '08 #1
5 3584
ronverdonk
4,258 Recognized Expert Specialist
We are here to help programmers with their PHP problems. And we can only help when we can see and work on the code you have developed.

So show it here and do not forget to enclose any code within the appropriate code tags!

Ronald
Mar 25 '08 #2
ghjk
250 Contributor
We are here to help programmers with their PHP problems. And we can only help when we can see and work on the code you have developed.

So show it here and do not forget to enclose any code within the appropriate code tags!

Ronald

This is my first dropdown(Thease are hard coded. no need to select from the database)
[HTML]<select name="name" id="name" >
<option value="Select" selected="selec ted">Select</option>
<option value="Fruit" >Fruit</option>
<option value="Country" >Country</option>
<option value="Game"> Game</option>
</select> [/HTML]

And second drop down should filled depend on the selected value in first dropdown.(get values from mysql database)
Mar 26 '08 #3
sethupnr
26 New Member
Expand|Select|Wrap|Line Numbers
  1. <!--
  2. ----------------------------
  3. here i juz worked in a localhost.
  4. database: demo1;
  5. table: demo_table;
  6. fields(demo_table)
  7.     item varchar(20);
  8.     list varchar(20);
  9. example table data( i here used a simple table structure u can use a well one):
  10. item    list
  11. fruit     Mango
  12. fruit     banana
  13. Country   India
  14. Country   USA
  15. Country   UK
  16. ----------------------------
  17. -->
  18. <html>
  19. <head>
  20. <title></title>
  21. <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
  22. <script type="text/javascript">
  23. function getItem(sel)
  24. {
  25.     var itemCode = sel.options[sel.selectedIndex].value;
  26.     //alert(itemCode);
  27.      var url= "http://localhost/onchange1.php?item="+itemCode;
  28. window.location=url;
  29.  
  30. }
  31. </script>
  32. </head>
  33.  
  34. <body>
  35.  
  36. <form action="" method="post">
  37. <table>
  38.     <tr>
  39.         <td>Item </td>
  40.         <td><select id="item" name="item" onchange="getItem(this)">
  41.             <option value="">Select </option>
  42.             <option value="Fruit">Fruit</option>
  43.             <option value="Country" >Country</option>
  44.                 </select>
  45.         </td>
  46.     </tr>
  47.     <tr>
  48.         <td>List </td>
  49.         <td><select id="item_list" name="item_list"  >
  50.         <option value="">Select </option>
  51.         <?php
  52. $i_code=$_REQUEST['item'];
  53.  
  54. $con = mysql_connect("localhost","root","");
  55. mysql_select_db("demo1",$con);
  56.  
  57. $query="select list from demo_table where item='$i_code'";
  58. $res=mysql_query($query);
  59. $num=mysql_num_rows($res);
  60. for($i=0;$i<$num;$i++)
  61. {
  62. $data=mysql_fetch_array($res);
  63. $v=$data[0].$i;
  64.  echo "<option value='$data[0]'>".$data[0]."</option>";
  65. }
  66. ?>
  67. </select>
  68. </td>
  69. </tr>
  70. </table>
  71. </form>
  72. </body>
  73. </html>
  74.  
it is a simplest method, and also u can use AJAX.
Apr 5 '08 #4
Atli
5,058 Recognized Expert Expert
Hi sethupnr.

Please use [code] tags when posting your code examples. (See How to ask a question)

[code=html] ...HTML code goes here... [/code]

Thank you.
Apr 5 '08 #5
proremmy
1 New Member
i have categories,then under each category,i want a sub category,all from database for example,categor y sells,then sub items and this is a menue in an html page from database,can u help plz
Nov 5 '11 #6

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

Similar topics

10
3467
by: Haines Brown | last post by:
I've implemented the horizontal drop down menu discussed recently in this newsgroup, and it works nicely under Galeon and Mozilla, but not IE 5.0. Here are the problems: Under IE 5.0, the there is no drop down menu functionality at all. I wanted to implement an alternative stylesheet for IE, but my link to it is apparently broken. What is wrong with my link? I'd
1
2673
by: objectref | last post by:
Hi to all, i have an app that i allow a drag and drop operation of picture boxes on a panel. when i drop a picture box i do the following so my newly dropped picture box will be able to respond to these 2 events: pbox.MouseDown += new MouseEventHandler(pbox_MouseDown); pbox.DoubleClick += new EventHandler(pbox_DoubleClick);
1
1430
by: Axel Gillert | last post by:
Hi! I search a way (in c#) to integrate my own application into the Windows-Desktop-Kontext-Menue (like ATI Hydravision, Catalyst Controlcenter ....), so that a user can start it by clicking right on the Desktop and selecting it from the menue. I need urgently a hint. Any help would be great.
3
6154
by: Don Wash | last post by:
Hi There! I have a Server-side Drop-down box in ASP.NET (VB) page. What do I do to widen the Drop down box's Pull-Down list's width? I'm not talking about the Drop-down box's width but the box that appear when user clicks the drop-down arrow button. Because items in the Drop down list are a little long, user can't see the full thing when they pull down the items from the drop down list.
2
12612
by: Yoshitha | last post by:
hi I have 2 drop down lists in my application.1st list ontains itmes like java,jsp,swings,vb.net etc.2nd list contains percentage i.e it conatains the items like 50,60,70,80,90,100. i will select any skill in 1st drop down list then i'll select % of this skill in the 2nd list box , based on the percentage i've selected in the 2nd list box it has to display 2 sets of drop down list boxes at run time one for selecting skill and
29
2362
by: Gregc. | last post by:
G'day I was wondering if someone can explain the concept of 'returning a Char from a Double' . For example, I have the following code: char getGrade(double mark) { if (mark>= 85) return ('A');
3
5945
by: ssoffline | last post by:
hi i have an app in which i can drop objects onto a form and move them, it consists of graphics (lines), i am using double buffering to avoid filckering in the parent control which is a panel,but when i add controls to this panel dyanamically, the double buffering effect is not there, i move all lines connceted to a control when the control is moved , at this time flickering occurs,also when i enable double buffering for a child control...
1
2317
by: Bobc003 | last post by:
Hi, I'd like to put a double drop-down menu on my webpage and instead of a redirection to a new webpage, I'd like to display the result in a new section. I'm kind of stuck and I only have a triple menu here. Here an exemple of what I need. (menu)Size, (menu) color and then display the price somewhere in a box. Thanks a bunch Bob
0
950
by: geoman | last post by:
Hello, Anyone know of and example that does this? Drop down 1 Select category Apples Peach Drop down 2 populated from 1 Apple pie
0
8356
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
8781
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
8551
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
8639
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...
1
6198
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
5664
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
4198
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...
0
4368
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
2
2011
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.