473,500 Members | 1,822 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

cascading dropdown menus

1 New Member
Hello everyone:
I need to make a dropdown menu that shows information depending on what the user chooses in the first one. I am using PHP and MySql.
I am new!

I looked for tutorials and I am trying to understand the code... however it is not clear enough. I will say what I understand so you can tell me where I am wrong.
Expand|Select|Wrap|Line Numbers
  1. <?PHP      
  2. require_once('connection.php');
  3. require_once('open_db.php');
  4.  
  5. $query1=mysql_query("SELECT Route_From as Desde FROM route") or die(mysql_error());
  6. $query2=mysql_query("SELECT * FROM route WHERE Route_From=".$_POST["Desde"]."&quot;") or die(mysql_error());
  7. ?>
  8.  
  9. <form name="check" method="post">
  10.    <!-- First Drop Down starts here -->
  11.       <select name="select1" onchange="this.form.submit()">
  12.          <?PHP
  13.             while ($row = mysql_fetch_assoc($query1)) 
  14.             {
  15.                 echo ("<option>{$row['Route_From']}</option>");
  16.             }
  17.           ?>
  18.       </select>
  19.  
  20.    <?PHP
  21.       if (isset($_POST["select1"]))
  22.    ?>
  23.    <select name="select2">
  24.    <?PHP
  25.       while($row = mysql_fetch_assoc($query2))
  26.       {
  27.          echo("<option>{$row['Route_To']}</option>");
  28.       }
  29.    ?>
  30.    </select>
  31. </form>
  32.  
Ok, so what I understand is:
- I connect to MySql (that works fine)
- I create the queries
- I create the first menu and start filling it up and with the "onchange", when a user selects an option, what he chose is submitted.
- When the first option is submitted, this info is captured with:
<?PHP
if (isset($_POST["select1"]))
?>
- The the second query is done and the second menu is filled.

When I execute the page the error that is shown is the following:
You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '"' at line 1

I hope someone can help me!
Bye
May 2 '07 #1
6 3683
ak1dnar
1,584 Recognized Expert Top Contributor
Replace this line and let me know the status.

[PHP]$query2=mysql_query('SELECT * FROM route WHERE Route_From='.$_POST['Desde'].'') or die(mysql_error());[/PHP]
May 3 '07 #2
rohitsavalia
8 New Member
Just replace your $query2 line with this :

$query2=mysql_query("SELECT * FROM route WHERE Route_From='".$_POST["Desde"]."'") or die(mysql_error());
May 4 '07 #3
wish
65 New Member
Hello,
I had faced same problem..if user select the item in <select> then the below got one textarea to display the description of item..what should i write the code..

from <select> i retrieve all the item from db and then i want based on the user select the item then show the description of the item that what user was selected..

Can some one guide me...
May 15 '07 #4
ak1dnar
1,584 Recognized Expert Top Contributor
wish,
After getting the result set row values print it in side the teaxarea.

[PHP]<textarea name="description" cols="5" rows="5"><? echo $the_description ?></textarea>[/PHP]
May 15 '07 #5
wish
65 New Member
Thank you my friend...
One problem is settle but another problem prompt out..
because based on the above example, the <form name="change" method="post"> the action property is no use then when i click button to submit..it can not work..if i add action property in the form tag then when i select the item then it direct go to another page...then what should i write the code...

Can you guide me again..
May 15 '07 #6
ak1dnar
1,584 Recognized Expert Top Contributor
Thank you my friend...
One problem is settle but another problem prompt out..
because based on the above example, the <form name="change" method="post"> the action property is no use then when i click button to submit..it can not work..if i add action property in the form tag then when i select the item then it direct go to another page...then what should i write the code...

Can you guide me again..
Its better to post a new thread for this question,Its not a good idea to continue with this tread here after.because this is not related to the thread of yo123.
May 15 '07 #7

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

Similar topics

0
1774
by: Humpty Dumpty | last post by:
Hi folks, here's a challenge: I have a dynamically created cascading menu in Tkinter that can be quite large because it is created from a file. I tried using lazy creation so only the menu item...
3
3566
by: michelle | last post by:
Hi all, I am new to Tk, or Python GUI programming and I seem to be stuck. I have looked about for help with Tk GUIs, but everything seems so terse or incomplete?? I have been mostly using the...
19
2842
by: chart43 | last post by:
I have question about the technique for css dropdown menus described in http://www.alistapart.com/articles/horizdropdowns/. Based on an html list, it has a few items in a 1st order list and further...
7
2701
by: Marci | last post by:
I found this script for cascading menus, however, I cannot reach the author to solve the bug I am having when I add a second menu to it. My problem is this: If I click on the first link, the...
1
1198
by: Cindy Lee | last post by:
is it possible to have cascading menus like: http://www.cracky.net/JAVA/Navigation/cascading-menu.html With scrollbars added, so you can only see a few options at a time? On some of my options...
2
4291
by: Ian | last post by:
Can anyone help me with a problem I have. What I need to be able to do is have the user presented with a single dropdown menu within a form using HTML <SELECT> and <OPTION>. Once they choose a...
1
1998
by: JMosey | last post by:
Not sure if this has been covered ( a google search came up pretty bare). I have a site that: - has multi-level cascading menus - floats center of the browser window - Will have fairly heavy...
0
1385
by: acadam | last post by:
Hi, I am trying to use cascading dropdown but I have some problems. The firts dropdown is ok, it's filled regularly... but the second dropdown is still disabled!! Why? I tried to start my...
3
3963
kcdoell
by: kcdoell | last post by:
I have 5 cascading combo boxes on a form. Below is a sample of my vb in the first combo box: Private Sub CboDivision_AfterUpdate() 'When the Division is selected, the appropriate Segment...
0
7182
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
7232
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...
1
6906
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
7397
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
5490
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,...
0
4611
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...
0
3110
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...
0
1430
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...
0
316
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence...

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.