Hi Torsten,
        I believe this is what I need, I'll give it a try, and I'll add the 
'onChange()' event as you say.
        I'll get back to the list once I did some extra effort trying this ;-)
        Kind regards,

Francisco


-----Original Message-----
From: Torsten Roehr [mailto:[EMAIL PROTECTED]
Sent: August 30, 2004 3:35 PM
To: [EMAIL PROTECTED]
Subject: [PHP] Re: PHP- Dependant dropdown based on Mysql queries


<Francisco Puente XFMP (QA/EMC)> wrote in message
news:[EMAIL PROTECTED]
> Hi All,
> I'm trying to generate a PHP page with 3 or 4 dropdown menus, each of one
dependant upon each other, that means:
> #2 dropdown should change upon selecting something on dropdown #1, #3
should change based on the selection at #2 to finally submit the desired
query. Each dropdown menu should be generated from a mysql query based on
the previous selection.
> I need to generate mysql queries based on each dropdown selection and the
page should reload the content for the next dropdown menu. I couldn't yet
figure out how to accomplish this.
> Let me know if I make myself clear enough :)
> Any help is very welcome!!
>
> Thanks in advance,
>
> Francisco

Hi Francisco,

just point the form action to $_SERVER['PHP_SELF']. Then check the POST
value of the relevant dropdown and do your queries. For example:

// the value of your selects will probably be ids that's why you should cast
them to integers

if (isset($_POST['select1'])) {
    $select1 = (int) $_POST['select1'];
    // do your query for select2
}

if (isset($_POST['select2'])) {
    $select2 = (int) $_POST['select2'];
    // do your query for select3
}

if (isset($_POST['select3'])) {
    $select3 = (int) $_POST['select3'];
    // do your query for select3
}

if (isset($_POST['select4'])) {
    $select4 = (int) $_POST['select4'];
    // insert your data
}

I hope you get my point. For user convenience you could use JavaScript's
onChange() event to auto-submit the first three selects when the user has
selected a value.

Best regards, Torsten Roehr

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to