close ad
WARNING: Do Not Install the DREAMWEAVER CC 2017 or 2018 Update »
open ad
View Menu

Technical Support Forums

Free, outstanding support from WebAssist and your colleagues

rating

Not sure where I've gone wrong...

Thread began 9/01/2011 11:20 am by iainmacdonald331081 | Last modified 9/02/2011 9:25 am by Jason Byrnes | 1564 views | 10 replies |

iainmacdonald331081

Not sure where I've gone wrong...

As above really - as far as I can tell I've followed the instruction, but this is the current state of my test page:

addProduct.php

One thing I wasn't sure about was the instruction to set them as lists, rather than drop down menus?

Anyway - I have attached a copy of the page, and would be grateful if someone could have a quick look and see if they can spot what I've missed.

Thanks again.

Attached Files
addProduct_WA.zip
Sign in to reply to this post

Jason ByrnesWebAssist

you have applied the Populate List from array behavior to the onchange event of the child form element.

it needs to be applied to the onchange event of the parent form element instead.

Sign in to reply to this post

iainmacdonald331081

Thanks Jason - have now changed that, but still isn't working here:

addProduct.php

I've attached a copy of the current page.

My database structure for the Parent and Child tables are as follows:

Parent:

Table: categories

Fields: category_ID, category

Table: subcategories: SubCategoryID, SubCategory, CategoryLinkID

Attached Files
addProduct_WA.zip
Sign in to reply to this post

Jason ByrnesWebAssist

in the category list, you are passing the category name as the value:
<option value="Cladding">Cladding</option>

it needs to pass the category id

Sign in to reply to this post

iainmacdonald331081

Thanks Jason - that's the drop downs working now:

addProduct.php

The last part now is that I'm not sure how to write the selected values into the database table (Products).

The Parent value (categories, category) needs to go into the field Main_Category, and the Child value (subcategories, SubCategory) into 1st_Sub.

The original insert code before the drop downs looked like:

// Add columns
$ins_Products->setTable("Products");
$ins_Products->addColumn("Category_ID", "NUMERIC_TYPE", "POST", "Category_ID");
$ins_Products->addColumn("Main_Category", "STRING_TYPE", "POST", "Main_Category");
$ins_Products->addColumn("Product_Code", "STRING_TYPE", "POST", "Product_Code");
$ins_Products->addColumn("1st_Sub", "STRING_TYPE", "POST", "1st_Sub");
$ins_Products->addColumn("2nd_Sub", "STRING_TYPE", "POST", "2nd_Sub");
$ins_Products->addColumn("Colour", "STRING_TYPE", "POST", "Colour");
$ins_Products->addColumn("Colour_image", "STRING_TYPE", "POST", "Colour_image");
$ins_Products->addColumn("Product_Description", "STRING_TYPE", "POST", "Product_Description");
$ins_Products->addColumn("Price", "DOUBLE_TYPE", "POST", "Price");
$ins_Products->addColumn("Image", "FILE_TYPE", "FILES", "Image");
$ins_Products->setPrimaryKey("Product_ID", "NUMERIC_TYPE");



I tried changing the relevant lines:

$ins_Products->addColumn("Main_Category", "STRING_TYPE", "POST", "Main_Category");
$ins_Products->addColumn("1st_Sub", "STRING_TYPE", "POST", "1st_Sub");



to the fields referenced in the drop downs:

$ins_Products->addColumn("Main_Category", "STRING_TYPE", "POST", "category");
$ins_Products->addColumn("1st_Sub", "STRING_TYPE", "POST", "SubCategory");



but that didn't seem to work.

Sign in to reply to this post

Jason ByrnesWebAssist

the select lists are not named category and SubCategory, they are named Parent and Child

$ins_Products->addColumn("Main_Category", "STRING_TYPE", "POST", "Parent");
$ins_Products->addColumn("1st_Sub", "STRING_TYPE", "POST", "Child");

Sign in to reply to this post

iainmacdonald331081

Nearly, but not quite - Parent inserts category_ID rather than category, and Child inserts SubCategoryID rather than SubCategory...

Sign in to reply to this post

Jason ByrnesWebAssist

it is supposed to work that way.


category and sub category names are defined in the category and subcategory tables.

in the product table, you want to store the category and sub category ID.

you return the associated name by using a join query.

for more details on join queries, see the following page:
sql_join.asp

Sign in to reply to this post

iainmacdonald331081

OK - I'm just about familiar with joins, link IDs etc, but was just keeping it simple here as per the instructions to get the dropdowns working.

So in the Products table I have the fields Main_Category and 1st_Sub which correspond to category in the Categories table and SubCategory in the subcategories table.

With the join, do I need to link the Products table to the categories and/or subcategories tables in the Parent and/or Child recordsets?

Sign in to reply to this post

iainmacdonald331081

Hold on - just looking at this again, and think I've figured out what I should be doing....

Should I basically drop the text fields from the main Products table for Category and SubCategory, but rather just have CategoryID and SubCategoryID.

And then have tables Categories and SubCategories.

And then in the pages that list each category, use the join query on those pages to look up Category and SubCategory in the Categories and SubCategories tables?

Sign in to reply to this post
loading

Build websites with a little help from your friends

Your friends over here at WebAssist! These Dreamweaver extensions will assist you in building unlimited, custom websites.

Build websites from already-built web applications

These out-of-the-box solutions provide you proven, tested applications that can be up and running now.  Build a store, a gallery, or a web-based email solution.

Want your website pre-built and hosted?

Close Windowclose

Rate your experience or provide feedback on this page

Account or customer service questions?
Please user our contact form.

Need technical support?
Please visit support to ask a question

Content

rating

Layout

rating

Ease of use

rating

security code refresh image

We do not respond to comments submitted from this page directly, but we do read and analyze any feedback and will use it to help make your experience better in the future.

Close Windowclose

We were unable to retrieve the attached file

Close Windowclose

Attach and remove files

add attachmentAdd attachment
Close Windowclose

Enter the URL you would like to link to in your post

Close Windowclose

This is how you use right click RTF editing

Enable right click RTF editing option allows you to add html markup into your tutorial such as images, bulleted lists, files and more...

-- click to close --

Uploading file...