Advertisement

08.12.2008 at 01:58PM PDT, ID: 23642777
[x]
Attachment Details
[x]
The Solution Rating System

With so many solutions, how can you tell which solutions are most likely to help you and which ones are not? To provide you with a tool to use, we rate our solutions based on various elements that most accurately determine if a solution is a quality solution. To explain what factors affect the solution rating, here are the elements we take into consideration when formulating our solution rating.

  • The Grade of the Solution
  • The Zone Rank of the Expert Providing the Solution
  • The Number of Author and Expert Comments
  • The Number of Experts Contributing
  • The Feedback of the Community

Your Input Matters
Because of the way the system is set up, the most important variable in this equation is you. As a member of Experts Exchange, you are able to cast your vote on the quality of the solutions in regard to how complete, accurate, helpful and easy to understand each solution is. When you provide your feedback, each rating is adjusted accordingly. So, if you see a solution that has a poor rating that you think is a good solution, let us know by rating it. As you do, the rating will be adjusted and will become more accurate for other members of our site.

If you have any suggestions that you would like to make for our rating system, please ask a question in the Suggestions Zone of Community Support.

Thank you!

9.0

Working with SQL Query and Arrays problem

Asked by skrodzkim in Active Server Pages (ASP), WebApplications

Tags:

I have a sql query (db is MySQL) that looks up a user entered value. The result is more than one line of data from the database. Let's say the user enters order_id number "456525", if you were to display the results in a html table, you would get three seperate lines, each with its own set of information. Like the following example:

ORDERID       ORDERNUMBER      QUANTITY
456525          413442                    10
456525          413442                    2
456525          413442                    26

I need to take this resulting set of data from the query and set each line to a unique session variable. So, the first result line would be...Session(PRODUCT1), the second line would be...Session(PRODUCT2) and so on. I believe that I need to use some sort of array but I have never used arrays and they are quite confusing after looking into how to use them.

So, after setting the results to session variables, I will then be using those variables for other queries later in the code. I know that if I need to use that data within the same page, I can just set the data to regular variable strings....but for other pages I will be using session variables. I hope that makes sense.
I have included the code that only uses one data string from the query, which works the way it is written.

I am definately confused on how arrays work. Maybe an example would help....

Thank you in advance!Start Free Trial
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
18:
19:
20:
21:
22:
23:
24:
25:
26:
27:
28:
29:
30:
31:
32:
33:
34:
35:
36:
37:
38:
39:
40:
41:
42:
43:
44:
45:
46:
47:
48:
49:
50:
51:
52:
53:
54:
55:
56:
57:
58:
59:
60:
61:
62:
63:
64:
65:
66:
67:
68:
69:
70:
71:
72:
73:
74:
75:
76:
77:
78:
79:
80:
81:
82:
83:
84:
85:
86:
87:
88:
89:
90:
91:
92:
93:
94:
95:
96:
97:
98:
99:
100:
101:
102:
103:
104:
105:
106:
107:
108:
109:
110:
111:
112:
113:
114:
115:
116:
117:
118:
119:
120:
121:
122:
123:
124:
125:
126:
127:
128:
129:
130:
131:
132:
133:
134:
135:
136:
137:
138:
139:
140:
141:
142:
143:
144:
145:
146:
147:
148:
149:
150:
151:
152:
153:
154:
155:
156:
157:
158:
159:
160:
161:
162:
163:
164:
165:
166:
167:
168:
169:
170:
171:
172:
173:
174:
175:
176:
177:
178:
179:
180:
181:
182:
183:
184:
185:
186:
187:
188:
189:
190:
191:
192:
193:
194:
195:
196:
197:
198:
199:
200:
201:
202:
203:
204:
205:
206:
207:
208:
209:
210:
211:
212:
213:
214:
215:
216:
217:
218:
219:
220:
221:
222:
223:
224:
225:
226:
227:
228:
<%@LANGUAGE="VBSCRIPT" CODEPAGE="1252"%>
<!--#include file="Connections/SYSTECHDB.asp" -->
<script type="text/Javascript">
function stripIt(x)
{
x.value = x.value.replace(/"/g,"");
};
</script>
<%
Dim VNUM
VNUM = "1"
If (Request.QueryString("vnum") <> "") Then 
  VNUM = UCase(Request.QueryString("vnum"))
End If
%>
<%
Dim rs1
Dim rs1_cmd
Dim rs1_numRows
 
Set rs1_cmd = Server.CreateObject ("ADODB.Command")
rs1_cmd.ActiveConnection = MM_SYSTECHDB_STRING
rs1_cmd.CommandText = "SELECT * FROM VEHICLEMASTER WHERE VEHICLE_NBR = '"&VNUM&"' AND COMP_NBR = '"&Session("COMP_NBR")&"'" 
rs1_cmd.Prepared = true
 
Set rs1 = rs1_cmd.Execute
rs1_numRows = 0
%>
<%
Dim ORDERNUM
ORDERNUM = "1"
If (Request.QueryString("ordernum") <> "") Then 
  ORDERNUM =(Request.QueryString("ordernum"))
End If 
%>
<%
Dim rs2
Dim rs2_cmd
Dim rs2_numRows
 
Set rs2_cmd = Server.CreateObject ("ADODB.Command")
rs2_cmd.ActiveConnection = MM_SYSTECHDB_STRING
rs2_cmd.CommandText = "SELECT * FROM DORDERS WHERE ORDER_NBR = '"&ORDERNUM&"' AND COMP_NBR = '"&Session("COMP_NBR")&"'" 
rs2_cmd.Prepared = true
 
Set rs2 = rs2_cmd.Execute
rs2_numRows = 0
%>
<%
Dim ORDERID
ORDERID = "1"
If ((rs2.Fields.Item("ORDER_ID").Value) <> "") Then 
  ORDERID =(rs2.Fields.Item("ORDER_ID").Value)
End If
%> 
<%
Dim rs3
Dim rs3_cmd
Dim rs3_numRows
 
Set rs3_cmd = Server.CreateObject ("ADODB.Command")
rs3_cmd.ActiveConnection = MM_SYSTECHDB_STRING
rs3_cmd.CommandText = "SELECT * FROM DORDERPRODUCTS WHERE ORDER_ID = '"&ORDERID&"'" 
rs3_cmd.Prepared = true
 
Set rs3 = rs3_cmd.Execute
rs3_numRows = 0
%>
<%
Dim PRODNBR
PRODNBR = "1"
If ((rs3.Fields.Item("PROD_NBR").Value) <> "") Then 
  PRODNBR =(rs3.Fields.Item("PROD_NBR").Value)
End If
%>
<%
Dim rs4
Dim rs4_cmd
Dim rs4_numRows
 
Set rs4_cmd = Server.CreateObject ("ADODB.Command")
rs4_cmd.ActiveConnection = MM_SYSTECHDB_STRING
rs4_cmd.CommandText = "SELECT * FROM PRODUCTMASTER WHERE PROD_NBR = '"&PRODNBR&"' AND COMP_NBR = '"&Session("COMP_NBR")&"'" 
rs4_cmd.Prepared = true
 
Set rs4 = rs4_cmd.Execute
rs4_numRows = 0
%>
<%
Dim VENDORABR
VENDORABR = "1"
If ((rs1.Fields.Item("VENDOR_ABR").Value) <> "") Then 
  VENDORABR =(rs1.Fields.Item("VENDOR_ABR").Value)
End If
%>
<%
Dim rs5
Dim rs5_cmd
Dim rs5_numRows
 
Set rs5_cmd = Server.CreateObject ("ADODB.Command")
rs5_cmd.ActiveConnection = MM_SYSTECHDB_STRING
rs5_cmd.CommandText = "SELECT * FROM VENDORS WHERE ABBREVIATION = '"&VENDORABR&"' AND COMP_NBR = '"&Session("COMP_NBR")&"'" 
rs5_cmd.Prepared = true
 
Set rs5 = rs5_cmd.Execute
rs5_numRows = 0
%>
<%
Dim rs6
Dim rs6_cmd
Dim rs6_numRows
 
Set rs6_cmd = Server.CreateObject ("ADODB.Command")
rs6_cmd.ActiveConnection = MM_SYSTECHDB_STRING
rs6_cmd.CommandText = "SELECT * FROM DORDERMESSAGES WHERE ORDER_ID = '"&ORDERID&"' AND MESSAGE_TYPE = '2' " 
rs6_cmd.Prepared = true
 
Set rs6 = rs6_cmd.Execute
rs6_numRows = 0
%>
<%
Session("VNUM") = (rs1.Fields.Item("VEHICLE_NBR").Value)
Session("ORDERNUM") = (rs2.Fields.Item("ORDER_NBR").Value)
Session("CUSTNAME") = (rs2.Fields.Item("CUST_NAME").Value)
Session("ORDERDATE") = (rs2.Fields.Item("ORDER_DATE").Value)
Session("JOBDESC") = Replace(rs2.Fields.Item("JOB_DESC").Value,"""","")
Session("TOTALQTY") = (rs3.Fields.Item("QUANTITY").Value)
Session("CUSTNUM") = (rs2.Fields.Item("CUST_NBR").Value)
Session("ZONE") = (rs2.Fields.Item("ZONE_NBR").Value)
Session("JOBNUM") = (rs2.Fields.Item("JOB_NBR").Value)
Session("PONUM") = (rs2.Fields.Item("PO_NBR").Value)
Session("CUSTPHONENUM") = (rs2.Fields.Item("CUST_PHONENBR").Value)
Session("ORDERLOC") = (rs2.Fields.Item("ORDER_LOC").Value)
Session("JOBDESC2") = ""
Session("JOBCITY") = (rs2.Fields.Item("JOBCITY").Value)
Session("JOBSTATE") = (rs2.Fields.Item("JOBSTATE").Value)
Session("JOBZIP") = ""
Session("PRODUCT1") = Replace(rs4.Fields.Item("PROD_DESC").Value,"""","") & " ---- " & (rs3.Fields.Item("QUANTITY").Value)&"TN"
Session("PRODUCT_CODE1") = (rs4.Fields.Item("PROD_NBR").Value)
Session("PRODUCT2") =
Session("PRODUCT_CODE2") =
Session("PRODUCT3") =
Session("PRODUCT_CODE3") =
Session("PRODUCT4") =
Session("PRODUCT_CODE4") =
Session("PRODUCT5") =
Session("PRODUCT_CODE5") =
Session("PRODUCT6") =
Session("PRODUCT_CODE6") =
Session("PRODUCT7") =
Session("PRODUCT_CODE7") =
Session("HAULER") = (rs5.Fields.Item("NAME").Value)
Session("TARE") = (rs1.Fields.Item("TARE_WEIGHT").Value)
Session("RUNNINGJOBTOT") = (rs2.Fields.Item("RUNNING_JOB_TOTALS").Value)
Session("INSTRUCTIONS") = (rs6.Fields.Item("MESSAGE_TEXT").Value)
%>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title>Order Summary</title>
<script type="text/Javascript">
 
 
 
function timeout(){
window.setTimeout("redirect()",300000)}
window.status = "Session will time out in 5 minutes!" ;
function redirect(){
window.location="default.asp"
return
}
</script>
 
<link href="css/style.css" rel="stylesheet" type="text/css" />
</head>
 
<body onLoad="timeout()">
<center>
<p>&nbsp;</p>
<p>&nbsp;</p>
<p class="style5">Your Vehicle Number: <em class="style7"><%=(rs1.Fields.Item("VEHICLE_NBR").Value)%></em></p>
<p class="style5">Your Order Number: <em class="style7"><%=(rs2.Fields.Item("ORDER_NBR").Value)%></em></p>
<p class="style5">Customer: <em class="style7"><%=(rs2.Fields.Item("CUST_NAME").Value)%></em></p>
<p class="style5">Job: <em class="style7"><%=(rs2.Fields.Item("JOB_DESC").Value)%></em></p>
<p class="style5">Order Date: <em class="style7"><%=(rs2.Fields.Item("ORDER_DATE").Value)%></em></p>
<p class="style5">Total Order: <em class="style7"><%=(rs3.Fields.Item("QUANTITY").Value)%></em> (Tons)</p>
<p class="style2">&nbsp;</p>
    <p class="style7">IS THIS CORRECT ? </p>
	<img border="0" id='button869' width="220" height="90" 
	src="images/button_yes_normal.jpg"
	onmouseover = 'document.getElementById("button869").src = "images/button_yes_mouseover.jpg"'
	onmouseout =  'document.getElementById("button869").src = "images/button_yes_normal.jpg"'
	onClick="window.location='weightcalc.asp'";>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
	<img border="0" id='button146' width="220" height="90" 
	src="images/button_no_normal.jpg"
	onmouseover = 'document.getElementById("button146").src = "images/button_no_mouseover.jpg"'
	onmouseout =  'document.getElementById("button146").src = "images/button_no_normal.jpg"'
	onClick="window.location='entervnum.asp'";>
</center>
</body>
</html>
 
<%
rs1.Close()
Set rs1 = Nothing
%>
<%
rs2.Close()
Set rs2 = Nothing
%>
<%
rs3.Close()
Set rs3 = Nothing
%>
<%
rs4.Close()
Set rs4 = Nothing
%>
<%
rs5.Close()
Set rs5 = Nothing
%>
<%
rs6.Close()
Set rs6 = Nothing
%>
[+][-]08.12.2008 at 02:52PM PDT, ID: 22217455

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 7-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]08.12.2008 at 05:41PM PDT, ID: 22218277

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 7-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]08.12.2008 at 05:43PM PDT, ID: 22218288

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 7-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]08.13.2008 at 11:49AM PDT, ID: 22224440

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 7-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]08.13.2008 at 11:53AM PDT, ID: 22224474

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 7-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]08.20.2008 at 09:16AM PDT, ID: 22271277

View this solution now by starting your 7-day free trial. Setting up your free trial is quick, easy, and secure. We will return you to this solution, unlocked, when you're done.

 

About this solution

Zones: Active Server Pages (ASP), WebApplications
Tags: ASP
Sign Up Now!
Solution Provided By: gregcmcse
Participating Experts: 1
Solution Grade: A
 
 
[+][-]08.20.2008 at 09:36AM PDT, ID: 22271501

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 7-day free trial to view this Author Comment or ask the Experts your question.

 
 
Loading Advertisement...
20080716-EE-VQP-32 / EE_QW_2_20070628