| ||||||||||||||||||||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
#1
|
|||
|
|||
|
Help with school project
hello every one, first time on here and looking for some help. i have this ASP code below: that connects to a database and displays it on a ASP page, the problem (by the way very very new to ASP ) i want to be able to add a quantity to the items and submit it to another page to view like a basket. for a project am doing. Still very losted in the world of ASP and any one can help me out i would be very greatful.
cheers chris <form action="orderfrom.asp" method="post" name="xboxconsole" id="xboxconsole"> <% Dim objConn Set objConn = Server.CreateObject("ADODB.Connection") objConn.ConnectionString="DRIVER={Microsoft Access Driver (*.mdb)};" & _ "DBQ=" & Server.MapPath("\game\database\db1.mdb") objConn.Open Dim objRS Set objRS = Server.CreateObject("ADODB.Recordset") objRS.Open "xboxconsoles", objConn, , , adCmdTable response.write "<table width=100% border=0 cellspacing=2 cellpadding=0 id=detailsxbox>" Do While Not objRS.EOF Dim strPicture dim id strPicture = objRS("picture") Response.Write "<tr><td><font color=#333333 size=3 face=Verdana, Arial, Helvetica, sans-serif><b>" & objRS("heading") & "</td></tr><tr>" response.write "<td><table width=100% border=0 cellspacing=2 cellpadding=0>" Response.Write "<tr><td><img src =" & strPicture &" ></td>" response.write "<td><table width=100% border=0 cellspacing=2 cellpadding=0><tr><td><b>Details</td></tr>" Response.Write "<tr><td><font color=#000000 size=2 face=Verdana, Arial, Helvetica, sans-serif>" & objRS("info") & "</td></tr>" Response.Write "<tr><td><font color=#FFFFCC size=3 face=Verdana, Arial, Helvetica, sans-serif><b>Only " & objRS("price") & "</td></tr>" response.write "</table></td>" Response.Write "</tr></table></td><tr>" Response.Write "<td><table width=100% border=0 cellspacing=2 cellpadding=0>" Response.Write "<tr><td>" &objRS("productcode")& "<b>Quantity:<select name=xboxq id=xboxq onChange=MM_jumpMenu(parent,this,0)><option value=>Select quantity</option><option value=1>1</option><option value=2>2</option><option value=3>3</option></select></td>" Response.Write "<td><input type=submit name=Submit value=Submit></td></tr>" Response.Write "</tr></table></td>" Response.Write "<tr><td><hr></td></tr></tr>" id = objRS("heading") & objRS("price") Response.Write id objRS.MoveNext loop objRS.close Set objRS = Nothing objConn.Close Set objConn = Nothing %> </form> |
|
#2
|
||||
|
||||
|
It looks like you have a good start...although I can't be sure(it's very hard to read your code without any formatting) It will make it easier for others to help you, and for you to debug your own code if you will use line breaks and indent like this:
Code:
dim id strPicture = objRS("picture") %>
<tr><td><font color=#333333 size=3 face=Verdana, Arial, Helvetica, sans-serif><b><%=objRS("heading")%></td></tr>
<tr><td>
<table width=100% border=0 cellspacing=2 cellpadding=0>
<tr><td><img src ="<%=strPicture%>"></td><td>
<table width=100% border=0 cellspacing=2 cellpadding=0>
<tr><td><b>Details</td></tr>
...etc... Also don't use response.write when you're outputting a lot of HTML code, it makes the HTML harder to read. You can print your variables to screen by putting the delimiters (<% %>) and an = sign (<%=myvariable%>). I know this wasn't your question, but I really didn't feel like reading through that jumbled mass of code to try to figure out exactly what you're doing. I hope it helps anyway ![]() |
|
#3
|
|||
|
|||
|
Hello mate
thanks for your reply and this is now i should of formated it first sorry about the mess above, just new to this site. i have this code that read's the information from a database ( works fine code below display page ) but i want the user to be able to pick items to add to the basket ( the problem) Code:
<form action="orderfrom.asp" method="get" name="xboxconsole" id="xboxconsole">
<%
Dim objConn
Set objConn = Server.CreateObject("ADODB.Connection")
objConn.ConnectionString="DRIVER={Microsoft Access Driver (*.mdb)};" & _
"DBQ=" & Server.MapPath("\game\database\db1.mdb")
objConn.Open
Dim objRS
Set objRS = Server.CreateObject("ADODB.Recordset")
objRS.Open "xboxconsoles", objConn, , , adCmdTable
response.write "<table width=100% border=0 cellspacing=2 cellpadding=0 id=detailsxbox>"
Do While Not objRS.EOF
Dim strPicture
Dim code
strPicture = objRS("picture")
code = objRS("productcode")
Response.Write "<tr><td><font color=#333333 size=3 face=Verdana, Arial, Helvetica, sans-serif><b>" & objRS("heading") & "</td></tr><tr>"
response.write "<td><table width=100% border=0 cellspacing=2 cellpadding=0>"
Response.Write "<tr><td><img src =" & strPicture &" ></td>"
response.write "<td><table width=100% border=0 cellspacing=2 cellpadding=0><tr><td><b>Details</td></tr>"
Response.Write "<tr><td><font color=#000000 size=2 face=Verdana, Arial, Helvetica, sans-serif>" & objRS("info") & "</td></tr>"
Response.Write "<tr><td><font color=#FFFFCC size=3 face=Verdana, Arial, Helvetica, sans-serif><b>Only " & objRS("price") & "</td></tr>"
response.write "</table></td>"
Response.Write "</tr></table></td><tr>"
Response.Write "<td><table width=100% border=0 cellspacing=2 cellpadding=0>"
Response.Write "<tr><td></td>"
Response.Write "<td><a HREF=orderfrom.asp?productcode=" & code & ">Order</A></td></tr>"
Response.Write "</tr></table></td>"
Response.Write "<tr><td><hr></td></tr></tr>"
objRS.MoveNext
loop
objRS.close
Set objRS = Nothing
objConn.Close
Set objConn = Nothing
%>
this is the code i have on my basket page that reads from a string but only gets the product code to the basket table in the database. ( see code below). is there a way that if i get the project code i will be able to fill in the rest of the table details from another table ??? Code:
<%
Dim objConn
Set objConn = Server.CreateObject("ADODB.Connection")
objConn.ConnectionString="DRIVER={Microsoft Access Driver (*.mdb)};" & _
"DBQ=" & Server.MapPath("\game\database\db1.mdb")
objConn.Open
Dim objRS
Dim objRS2
dim strVar1
strVar1 = request.querystring("productcode")
Set objRS2 = Server.CreateObject("ADODB.Recordset")
objRS2.Open "basket", objConn, ,adLockOptimistic , adCmdTable
Set objRS = Server.CreateObject("ADODB.Recordset")
objRS.Open "xboxconsoles", objConn, ,adLockOptimistic , adCmdTable
objRS2.addnew
objRS2("productcode") = request.querystring("productcode")
objRS2.Update
objRS2.MoveFirst
Do while not objRS.EOF
if objRS2("productcode") = objRS("productcode") then
objRS2("price")= objRS("price")
objRS2("heading")= objRS("heading")
objRS2.Update
end if
objRS2.MoveNext
loop
Response.Write strVar1
objRS2.close
Set objRS2 = Nothing
objRS.close
Set objRS = Nothing
objConn.Close
Set objConn = Nothing
%>
thanks for your time chris |
|
#4
|
||||
|
||||
|
is
<a HREF=orderfrom.asp?productcode=" & code & ">Order</A> supposed to add the item to the cart? |
|
#5
|
||||
|
||||
|
So, then you need a tbl to track your orders. When the user clicks "order" the order is added to that table.
|
![]() |
| Viewing: ASP Free Forums > Programming > Code Bank > Help with school project |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|
|