开发者

dynamically display category, subcategory, products using coldfusion

开发者 https://www.devze.com 2022-12-08 00:33 出处:网络
please help me with this school project for an e-commerce site that im doing ryt now..im a newbie in programming..

please help me with this school project for an e-commerce site that im doing ryt now..im a newbie in programming.. here's the scenario..

Im using coldfusion,ms access,dwcs3 How can I dynamically view the products that are base on dynamic category and subcategory? using URL parameters

here is my table on my msaccess

tblcategory

fieldname datatype

category text

subcategory text

tblproduct

ProductID text

Subcategory text

enter code here

Description text

I already show dynamically the category and subcategory but I can't find a solution to show the products base on it's category and subcategory

here's my code

<cfparam name="URL.Category" default="1">

<cfquery name="rs_category" datasource="Database">
SELECT DISTINCT category
FROM tblcategory 
</cfquery>

<cfquery name="rs_subcategory" datasource="Database">
<cfif category eq 1>
SELECT *
FROM tblcategory
<cfelse>
SELECT *
FROM tblcategory
WHERE Category = <cfqueryparam value="#URL.Category#" cfsqltype="cf_sql_clob" maxlength="50"> 
</cfif>
</cfquery>


<body>

 <cfoutput query="rs_category"><a href="dynamic.cfm?category=#rs_category.category#">#rs_category.category#</a><br />
</cfoutput> 


<br />
<cfoutput query="rs_subcategory">#rs_subcategory.Subcategory#<br />
</cfoutput>
<br />


</body>
</html>

sample output

category(dynamic category)

Electrical (when click show electrical subcategory)
Steel
Wood

subcategory(base on the category dynamically show the subcategory)

Phelps dodge  
Metro Wire

Wire Spool

( I need to s开发者_如何学JAVAhow the products that are under the same category and subcategory dynamically)

(This is the part that I need to know... so can someone who has experience in cf can help me..)


Do you want multiple drop downs / select fields to drill down to the product?

If so check out these two links:

http://www.forta.com/blog/index.cfm/2007/5/31/ColdFusion-Ajax-Tutorial-2-Related-Selects

http://forums.forta.com/messages.cfm?threadid=A23B65BE-3048-80A9-EFE12A313B4A9E72


It looks like you are headed in the right direction. First, I'd like to say a big bravo for using cfsqlparam. Now, to the advice.

First, always scope url.category when referring to what you are passing in on the command line.

So, if we want to display links to the subcategories, I would probably do something like this:

<cfoutput query="rs_subcategory">
     <a href="dynamic.cfm?category=#urlencodedformat(url.category)#&subcategory=#urlencodedformat(subcategory)#">
         #htmleditfomrat(rs_category.subcategory)#
     </a>
     <br />
</cfoutput> 

Now, you need to do the lookup in the db for products based on url.category and url.subcategory, just as you did looking up the subcategories based on category.

If you need additional assistance, please clarify what you need help with, as your question is pretty broad.

0

精彩评论

暂无评论...
验证码 换一张
取 消