close ad
 
Important WebAssist Announcement
open ad
View Menu

Technical Support Forums

Free, outstanding support from WebAssist and your colleagues

rating

Product Categories

Thread began 10/28/2013 6:05 am by Jamie | Last modified 10/30/2013 6:24 am by Jason Byrnes | 2978 views | 19 replies |

Jamie

Product Categories

Hey Jason

Just looking for your opinion as to the best way to allow a client to add/edit product categories - my thinking is to just create an insert/update set of pages just for the category options? Is there a more elegant/efficient way to achieve this?

Thanks

Jamie

Sign in to reply to this post

Jason ByrnesWebAssist

depends on how you want categories to work.


You may create a many to one relation of products to categories or a many to many relation of products to categories.

which you chose will determine the way to implement categories.

Sign in to reply to this post

Jamie

sorry to be thick but for clarification, when you say many to one vs many to many do you mean

many products to one categeory vs products being able to be associated with all/many of the categories?

Sign in to reply to this post

Jason ByrnesWebAssist

one category for each product

- store selected category ID in products table

versus products belonging to multiple categories

- use a productcategories linking table, this is similar to the genres example in the Manage relational table tutorial.

Sign in to reply to this post

Jamie

When you say one category for each product, I am assuming you mean that although there may be multiple categories, each product would only be a member of one category?

Basically, if I am setting up a grocery shop with, let's say, categories of cheese, meat, beer...then you would have multiple products within each cat? Such as in cheese cat you could have product of cheddar, Camembert, Brie etc etc?

That being the case... Should I set up a category insert/update page for the client to be able to add/edit or remove categories and then create a dynamic list of each category which then populates with the product associated with it?

Sign in to reply to this post

Jason ByrnesWebAssist

  When you say one category for each product, I am assuming you mean that although there may be multiple categories, each product would only be a member of one category?  



yes, that is what i mean.

if you are doing it this way, a product can onlt belong to one category, the create the category add / update pages

then on the product page, add a select list to select the associated category.

populate it from the category table using the category ID as the value.

in the product Insert / update behavior, bind the category column of the products table to the select list.

Sign in to reply to this post

Jamie

thanks for the clarification and pointer... got that all working.

what I havent managed to get working is that when in the update page, the category that is showing as the selected one is always the top category rather than the one that was selected.

<select name="ProductCategory">
<?php do { ?>
<option value="<?php echo $row_Categories['CategoryID']; ?>" ><?php echo $row_Categories['CategoryName']; ?></option>
<?php } while ($row_Categories = mysql_fetch_assoc($Categories)); ?>
</select>



Have attached the file if if helps...

Cheers

Sign in to reply to this post

Jason ByrnesWebAssist

in design view, select the category list.

in the property inpsector, click the dynmaic button.

click the lightning bolt next to the Select Value Equal to and select the category column from the products recordset.

Sign in to reply to this post

Jamie

thanks JAson but that hasnt made any difference at all... the drop down is still showing the topmost item as the default

edit sorry just to clarify, I have tried using both the category recordset and the product recordset to do this without any success and this is the code I currently have:

<select name="ProductCategory">
<option value="<?php echo $row_Categories['CategoryID']; ?>" <?php if (!(strcmp($row_Categories['CategoryName']))) {echo "selected=\"selected\"";} ?>><?php echo $row_Categories['CategoryName']; ?></option>

</select>



and this is giving me 'wrong parameter count for strcomp ().....

Sign in to reply to this post

Jason ByrnesWebAssist

you used the category name column from the categories recordset.

use the category column from the products recordset.

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