Re: [PHP-DB] Associated popup menu (php/mysql)
Hi all, This is exactly what I meant. I thought that this operation could be done without any JS. But this not seems to be the correct way. Definitively a mix of languages must be used. Thank you all for your responses. David -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP-DB] Associated popup menu (php/mysql)
Let's see if I'm understanding you correctly. You want to have a form with 2 or more popup menus, where a choice of `country` in the first menu then populates a second popup menu with the `states` located in that country? If this is what you're asking, I do this all the time using select (or drop down) boxes in html (with PHP, JavaScript, and a MySQL back-end). Perhaps it can be used also for pop-ups...? The basics are to have the form submit to itself, have the database query selecting all `countries` populate the first menu when the page is first displayed by running a "select id_country, country from Countries" query against your database, then use the id_country of the selected country to run a second query, "select state_names from states where id_country = {$_POST['value_returned_from_first_query']}". I usually use 'onchange=\"this.form.submit()\"' to automate the submittal of the form/page. Use conditional statements in your PHP code to control which queries get run, that is, only run the second query if the variable for the selected country has a value in it. The PHP manual has lots of examples about how to use built-in functions for a variety of databases to query and retrieve data. HTH, dave >Hello all, > >I've been searching for hours and cannot find the answer or sample in in any >forum. > >What is the best method (any sample or help would be appreciated), to >associate popup menus in a form. Choosing the first popup menu (Main >categorie) should provide to me the results for the second popup menu >(subcategory). > >Ie : Countries --> states > >I know that javascript can do this sort of things, but I would like to use >only php. Is that possible ? > >I have two tables in mysql: Countries & states that can be associated by >id_country.
Re: [PHP-DB] Associated popup menu (php/mysql)
By "pop-up" do you really mean "pop-up" or rather drop-down boxes? Have a look at the PEAR Quickform class and its "hierselect" form element (hierarchical dropdown boxes) http://pear.php.net/manual/en/package.html.html-quickform.tutorial.php HTH Ignatius _ - Original Message - From: "Micah Stevens" <[EMAIL PROTECTED]> To: <[EMAIL PROTECTED]> Sent: Friday, February 06, 2004 02:33 Subject: Re: [PHP-DB] Associated popup menu (php/mysql) > > Javascript is client side programming, PHP is server side and unable to > control actions and make decisions on what's happening in the browser except > in a 'third person' manner. > > Simply put, you can't do this with PHP. > > > > > On Thu February 5 2004 5:21 pm, alb_shop wrote: > > Hello all, > > > > I've been searching for hours and cannot find the answer or sample in in > > any forum. > > > > What is the best method (any sample or help would be appreciated), to > > associate popup menus in a form. Choosing the first popup menu (Main > > categorie) should provide to me the results for the second popup menu > > (subcategory). > > > > Ie : Countries --> states > > > > I know that javascript can do this sort of things, but I would like to use > > only php. Is that possible ? > > > > I have two tables in mysql: Countries & states that can be associated by > > id_country. > > > > Thank you > > -- > PHP Database Mailing List (http://www.php.net/) > To unsubscribe, visit: http://www.php.net/unsub.php > > -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP-DB] Associated popup menu (php/mysql)
Javascript is client side programming, PHP is server side and unable to control actions and make decisions on what's happening in the browser except in a 'third person' manner. Simply put, you can't do this with PHP. On Thu February 5 2004 5:21 pm, alb_shop wrote: > Hello all, > > I've been searching for hours and cannot find the answer or sample in in > any forum. > > What is the best method (any sample or help would be appreciated), to > associate popup menus in a form. Choosing the first popup menu (Main > categorie) should provide to me the results for the second popup menu > (subcategory). > > Ie : Countries --> states > > I know that javascript can do this sort of things, but I would like to use > only php. Is that possible ? > > I have two tables in mysql: Countries & states that can be associated by > id_country. > > Thank you -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php