Snitz Forums 2000
Snitz Forums 2000
Home | Profile | Register | Active Topics | Members | Search | FAQ
Username:
Password:
Save Password
Forgot your Password?

 All Forums
 Community Forums
 Code Support: ASP (Non-Forum Related)
 how can i do this?
 New Topic  Topic Locked
 Printer Friendly
Author Previous Topic Topic Next Topic  

redbrad0
Advanced Member

USA
3725 Posts

Posted - 25 May 2001 :  09:03:46  Show Profile  Visit redbrad0's Homepage  Send redbrad0 an AOL message
I have been working on an e-commerce site and i would like to give some customers different prices for products. so im trying to figure out the best way to do this.

i dont want to add extra columns for each product in the customers table because i want to be able to add and delete products eazy. so im thinking maybe have another table called product_prices. This table would not be used for everyone, but if the customer is logged in, then it will check before each price is displayed to see if they have that product at a better price. so here is kinda how the table would be laid out.

price_id = unique id
customer_id = customers user number
product_id = products_id
customer_price = price the customer gets it at.

so then i could basically do a sql string like this...


<%
strSql = "SELECT customer_price"
strSql = strSql & " FROM product_prices"
strSql = strSql & " WHERE customer_id='" & SQLencode(strCookieCustomerID) & "'"
strSql = strSql & " AND product_id='" & SQLencode(strProductID) & "'"
set rs = my_Conn.Execute (strSql)

if rs.eof or rs.bof then
strProductPrice = strOldProductPrice
else
strProductPrice = rs("customer_price")
end if

Response.Write "This product will cost you " & strProductPrice & "!"
%>


Brad

Edited by - redbrad0 on 25 May 2001 09:05:24

redbrad0
Advanced Member

USA
3725 Posts

Posted - 25 May 2001 :  15:34:10  Show Profile  Visit redbrad0's Homepage  Send redbrad0 an AOL message
anyone have any comments on this?

Brad
Go to Top of Page

big9erfan
Average Member

540 Posts

Posted - 25 May 2001 :  17:08:23  Show Profile
Basically you are normalizing your data to prevent insertion/deletion errors.

This is probably the best way to do it as long as you keep the Product_Prices ( though customer_Prices is probably a better description for this table as it is unique prices for a customer on each product ).

It should work quite well for you. ( I hope?!? )

http://www.ugfl.net/forums
Go to Top of Page

redbrad0
Advanced Member

USA
3725 Posts

Posted - 25 May 2001 :  19:00:16  Show Profile  Visit redbrad0's Homepage  Send redbrad0 an AOL message
well i am going to try and code it this weekend. i believe that it will be very easy and i just hope it will not hurt performance any

Brad
Go to Top of Page
  Previous Topic Topic Next Topic  
 New Topic  Topic Locked
 Printer Friendly
Jump To:
Snitz Forums 2000 © 2000-2021 Snitz™ Communications Go To Top Of Page
This page was generated in 0.27 seconds. Powered By: Snitz Forums 2000 Version 3.4.07