Thanks Elias,

I took a look at the code and there are indeed many things to learn;
however, it's all in js.
I'm trying to have php write the js, but I don't know enough about arrays
and manipulating their elements.

Roger

-----Original Message-----
From: lallous [mailto:[EMAIL PROTECTED]]
Sent: Wednesday, September 11, 2002 2:02 AM
To: [EMAIL PROTECTED]
Subject: [PHP] Re: Dependent Dropdown Boxes

Hi,

Try to learn many things from the test code i created below:

http://lgwm.org/ozone/dynatable.htm

Good luck,

Elias

"Roger Lewis" <[EMAIL PROTECTED]> wrote in message
[EMAIL PROTECTED]">news:[EMAIL PROTECTED]...
> The Situation:
>
> I'm trying to create a pair of dynamic dropdown boxes where the options in
> the second box are dependent on the selection in the first box.  I call
the
> first box "categories" and the second, "subcategories".  I want to store
the
> categories and subcategories in a mysql table(s) so that a user can
> dynamically update them.  Currently, I have a single table called
> categories, with columns: id, category, and subcategory.
>
> The primary code for selecting the options for the second box is in
> javascript.  This code makes use of the following datasets for storing the
> various categories and subcategories.  If I can get php to generate this
> text, then the dependent boxes will work.
>
> datasets=new Array();
>
datasets[0]="Category1,subCategory1_1,subCategory1_2,subCategory1_3,subCateg
> ory1_4".split(",");
>
datasets[1]="Category2,subCategory2_1,subCategory2_2,subCategory2_3".split("
> ,");
> datasets[2]="Category3,subCategory3_1, subCategory3_2,
> subCategory3_3,subCategory3_4,subCategory3_5".split(",");
>
datasets[3]="Category4,subCategory4_1,subCategory4_2,subCategory4_3,subCateg
> ory4_4".split(",");
>
datasets[4]="Category5,subCategory5_1,subCategory5_2,subCategory5_3,subCateg
> ory5_4,subCategory5_5,subCategory5_6".split(",");
> etc.
>
> The Problem:
>
> Using the following code I can get php to print the results, but only in a
> line-by-line, category/subcategory format.  Of course, this is NOT what is
> needed.  Each subcategory name should be on the same line as its
associated
> category.
>
> <?php
> $dbConnect = mysql_connect("localhost", "root", "pwd");
> mysql_select_db("new_kb",$dbConnect);
> $sql = "SELECT * from categories";
> $result = mysql_query($sql);
> for ($count = 1; $row = mysql_fetch_row ($result); ++$count)
> {
> print "<br>datasets[$count]=\"";
> print "$row[1],";
> print "$row[2]\"";
> }
> ?>
>
>
> datasets[0]="Category1,subCategory1_1
> datasets[1]="Category1,subCategory1_2
> datasets[2]="Category1,subCategory1_3
> datasets[3]="Category1,subCategory1_4
> datasets[4]="Category2,subCategory2_1
> datasets[5]="Category2,subCategory2_2
> etc.
>
> Can someone explain how to write the php code to output the category and
> subcategory names from the mysql table to match the javascript format
above.
>
> Thanks in advance for any help or suggestions.
>
> Roger Lewis
>
>
>



--
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