ghjk 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?
5 3584
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
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)
-
<!--
-
----------------------------
-
here i juz worked in a localhost.
-
database: demo1;
-
table: demo_table;
-
fields(demo_table)
-
item varchar(20);
-
list varchar(20);
-
example table data( i here used a simple table structure u can use a well one):
- item list
-
fruit Mango
-
fruit banana
-
Country India
-
Country USA
-
Country UK
-
----------------------------
-
-->
-
<html>
-
<head>
-
<title></title>
-
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
-
<script type="text/javascript">
-
function getItem(sel)
-
{
-
var itemCode = sel.options[sel.selectedIndex].value;
-
//alert(itemCode);
-
var url= "http://localhost/onchange1.php?item="+itemCode;
-
window.location=url;
-
-
}
-
</script>
-
</head>
-
-
<body>
-
-
<form action="" method="post">
-
<table>
-
<tr>
-
<td>Item </td>
-
<td><select id="item" name="item" onchange="getItem(this)">
-
<option value="">Select </option>
-
<option value="Fruit">Fruit</option>
-
<option value="Country" >Country</option>
-
</select>
-
</td>
-
</tr>
-
<tr>
-
<td>List </td>
-
<td><select id="item_list" name="item_list" >
-
<option value="">Select </option>
-
<?php
-
$i_code=$_REQUEST['item'];
-
-
$con = mysql_connect("localhost","root","");
-
mysql_select_db("demo1",$con);
-
-
$query="select list from demo_table where item='$i_code'";
-
$res=mysql_query($query);
-
$num=mysql_num_rows($res);
-
for($i=0;$i<$num;$i++)
-
{
-
$data=mysql_fetch_array($res);
-
$v=$data[0].$i;
-
echo "<option value='$data[0]'>".$data[0]."</option>";
-
}
-
?>
-
</select>
-
</td>
-
</tr>
-
</table>
-
</form>
-
</body>
-
</html>
-
it is a simplest method, and also u can use AJAX.
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.
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
Sign in to post your reply or Sign up for a free account.
Similar topics |
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
|
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);
|
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.
|
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.
|
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
| |
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');
|
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...
|
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
|
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
|
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,...
|
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...
| |
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,...
|
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...
|
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...
|
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();...
|
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...
|
by: adsilva |
last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
| |
by: muto222 |
last post by:
How can i add a mobile payment intergratation into php mysql website.
| |