I
isaac2004
hello i am making a spoof online book store site for a class and I was
wondering how i could fix a problem i am having. I have two tables, one
the cart and the other a table with book descriptions. what i am trying
to do is display the book info for the cart through a SQL statement.
the only problem is when i do this it just outputs the info for all
books in the database. how would i change my SQL statement to only read
the info for the books listed as ISBNs in the cart.
here is a code snippet watch for text wraps
' count total items in shopping cart
dim intItemCount, dblPrice, curDiscPrice, curPrice, dblSubTotal
dim dblShipping, dblTotalPrice
strSQL="SELECT tblCart.strSessionID, Sum(tblCart.intQty) AS SumOfintQty
" & _
"FROM tblCart " & _
"GROUP BY tblCart.strSessionID " & _
"HAVING tblCart.strSessionID='" & strSessionID & "'"
objRS.Open strSQL, objConn
If NOT objRS.EOF then
intItemCount = objRS("SumOfintQty")
else
intItemCount = 0
end if
objRS.Close
'List items in cart
If intItemCount < 1 then
response.write "<center><font face='Comic Sans MS'
color='#FF0000'>" & _
"Your Shopping Cart is empty.</font><br><br>"
Else
strSQL="SELECT tblCart.strSessionID, tblCart.strISBN,
tblCart.intQty, tblBookDescription.ISBN, tblBookDescription.strTitle,
tblBookDescription.dblPrice " & _
"FROM tblBookDescription, tblCart " & _
"WHERE tblCart.strSessionID='" & strSessionID & "'"
objRS.Open strSQL, objConn
%>
<div align="center">
<center>
<font face='Comic Sans MS' color='#FF0000'>You have <%
=intItemCount %>
book<% If intItemCount > 1 then response.write "s" %> in
your shopping cart.
</font><br><br>
<table cellpadding="4">
<tr>
<td>Item</td>
<td>Book Title</td>
<td>Qty</td>
<td>Price</td>
<td> </td>
<td> </td>
</tr>
<%
'List each item in cart
dim intCount
do while NOT objRS.EOF
intCount = intCount + 1
%>
<tr>
<td><% =intCount %>.</td>
<td>
<! Book Title, author, stock >
<a href="ProductPage.asp?isbn= <% =objRS("ISBN")%> "> <%
=objRS("strTitle")%> </a>
<br>
<font size="-1">
by <% =funListAuthors(objRS("ISBN")) %></a>
</font>
<br>
</td>
<td><% =objRS("intQty") %></td>
<td>
<% curPrice = FormatCurrency(objRS("dblPrice"))
curDiscPrice = FormatCurrency((objRS("dblPrice")*.8))
dblPrice = (objRS("dblPrice"))
%>
<! Price >
<FONT face=arial,verdana,helvetica><B>List Price:
<font color=#990000><strike><% =dblPrice
%></strike></font><br>
<FONT face=arial,verdana,helvetica>Our Price:
<font color=#990000> <% =curDiscPrice %> </font><br>
<FONT face=arial,verdana,helvetica>You Save:
<font color=#990000><% =FormatCurrency((dblPrice -
curDiscPrice)) %>(20%)</b></font><br><br>
<td><a href="?delISBN=<% =objRS("strISBN")
%>"> Remove</a></td>
<td><a href="?addISBN=<% =objRS("strISBN")
%>"> Add</a></td>
</tr>
<% objRS.MoveNext
Loop
%> </table>
thanks for the help if you have any questions just ask
Isaac
wondering how i could fix a problem i am having. I have two tables, one
the cart and the other a table with book descriptions. what i am trying
to do is display the book info for the cart through a SQL statement.
the only problem is when i do this it just outputs the info for all
books in the database. how would i change my SQL statement to only read
the info for the books listed as ISBNs in the cart.
here is a code snippet watch for text wraps
' count total items in shopping cart
dim intItemCount, dblPrice, curDiscPrice, curPrice, dblSubTotal
dim dblShipping, dblTotalPrice
strSQL="SELECT tblCart.strSessionID, Sum(tblCart.intQty) AS SumOfintQty
" & _
"FROM tblCart " & _
"GROUP BY tblCart.strSessionID " & _
"HAVING tblCart.strSessionID='" & strSessionID & "'"
objRS.Open strSQL, objConn
If NOT objRS.EOF then
intItemCount = objRS("SumOfintQty")
else
intItemCount = 0
end if
objRS.Close
'List items in cart
If intItemCount < 1 then
response.write "<center><font face='Comic Sans MS'
color='#FF0000'>" & _
"Your Shopping Cart is empty.</font><br><br>"
Else
strSQL="SELECT tblCart.strSessionID, tblCart.strISBN,
tblCart.intQty, tblBookDescription.ISBN, tblBookDescription.strTitle,
tblBookDescription.dblPrice " & _
"FROM tblBookDescription, tblCart " & _
"WHERE tblCart.strSessionID='" & strSessionID & "'"
objRS.Open strSQL, objConn
%>
<div align="center">
<center>
<font face='Comic Sans MS' color='#FF0000'>You have <%
=intItemCount %>
book<% If intItemCount > 1 then response.write "s" %> in
your shopping cart.
</font><br><br>
<table cellpadding="4">
<tr>
<td>Item</td>
<td>Book Title</td>
<td>Qty</td>
<td>Price</td>
<td> </td>
<td> </td>
</tr>
<%
'List each item in cart
dim intCount
do while NOT objRS.EOF
intCount = intCount + 1
%>
<tr>
<td><% =intCount %>.</td>
<td>
<! Book Title, author, stock >
<a href="ProductPage.asp?isbn= <% =objRS("ISBN")%> "> <%
=objRS("strTitle")%> </a>
<br>
<font size="-1">
by <% =funListAuthors(objRS("ISBN")) %></a>
</font>
<br>
</td>
<td><% =objRS("intQty") %></td>
<td>
<% curPrice = FormatCurrency(objRS("dblPrice"))
curDiscPrice = FormatCurrency((objRS("dblPrice")*.8))
dblPrice = (objRS("dblPrice"))
%>
<! Price >
<FONT face=arial,verdana,helvetica><B>List Price:
<font color=#990000><strike><% =dblPrice
%></strike></font><br>
<FONT face=arial,verdana,helvetica>Our Price:
<font color=#990000> <% =curDiscPrice %> </font><br>
<FONT face=arial,verdana,helvetica>You Save:
<font color=#990000><% =FormatCurrency((dblPrice -
curDiscPrice)) %>(20%)</b></font><br><br>
<td><a href="?delISBN=<% =objRS("strISBN")
%>"> Remove</a></td>
<td><a href="?addISBN=<% =objRS("strISBN")
%>"> Add</a></td>
</tr>
<% objRS.MoveNext
Loop
%> </table>
thanks for the help if you have any questions just ask
Isaac