VP-ASP :: Shopping Cart Software

Shopping Cart Software Solutions for anywhere in the World

US/Canada(Toll Free): +1 888 587 2278
Europe/UK: +44 (020) 7193 9408
Australia/New Zealand: +61 3 9016 4497

VP-ASP Shopping Cart Customer Forum

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

 All Forums
 VPCart Forum
 General help me questions
 Parent-child products
 New Topic  Reply to Topic
 Printer Friendly
Author Previous Topic Topic Next Topic  

aprilynm
Starting Member

USA
29 Posts

Posted - December 26 2012 :  23:28:25  Show Profile  Reply with Quote
My product table has parent and child products in whatever order they were entered. For inventory, it would be great to have the parent and child products together. Can anyone help me write a query to return each parent product followed by its child products?

Thanks and happy holidays!

Aprilynm

Aprilynm

Edited by - aprilynm on December 26 2012 23:29:13

zachary
Starting Member

29 Posts

Posted - December 27 2012 :  01:45:58  Show Profile  Reply with Quote
Hi Aprilynm,

I got a script sample here, hope it helps:

You just need to put the script below in a ".asp" page & upload to your VPASP Root then you are able to test it.

<%option explicit%>
<%response.buffer=true%>
<!--#include file="shop$db.asp"-->
<%ShopOpenDatabase dbc%>
<%
displayproduct
sub displayproduct
dim sql,rs,selected
sql="select * from products where hassubproduct='Yes'"
Set rs = Server.CreateObject("ADODB.Recordset")
rs.open sql, dbc, adOpenForwardOnly, adLockReadOnly
if not rs.eof then
do while not rs.eof
debugwrite "<b>"&rs("cname") &" - "& rs("ccode") &"</b>"
getchildproduct rs("catalogid")
rs.movenext
loop
end if
end sub

Sub getchildproduct(parentid)
dim sql2,rs2,selected
sql2="select * from products where highercatalogid = "&parentid
Set rs2 = Server.CreateObject("ADODB.Recordset")
rs2.open sql2, dbc, adOpenForwardOnly, adLockReadOnly
if not rs2.eof then
do while not rs2.eof
debugwrite "     - " & rs2("cname") &" - "& rs2("ccode")
rs2.movenext
loop
end if
end sub
%>

<%ShopCloseDatabase dbc%>

Thanks
Zach
Go to Top of Page

aprilynm
Starting Member

USA
29 Posts

Posted - December 27 2012 :  15:14:43  Show Profile  Reply with Quote
Zach,

This did the trick. Thanks so very much!

April

Aprilynm
Go to Top of Page
  Previous Topic Topic Next Topic  
 New Topic  Reply to Topic
 Printer Friendly
Jump To:
Snitz Forums 2000