Click to See Complete Forum and Search --> : Dates in ASP


bumcheekcity
06-04-2004, 05:28 PM
<%
dim strid, strquery, intnumrows, intcount, strorderplaced
dim userid(), quantity(), medicineid(), username(), medid2(), description(), dateplaced(), datedispatched(), datearrived(), orderid()
strid = session("id")
strquery = "SELECT * FROM orders WHERE chemist_id = "&strid&" AND collected = 0"
objrecordset.open strquery,objdatabase,1,2
intnumrows = objrecordset.recordcount
redim userid(intnumrows)
redim quantity(intnumrows)
redim medicineid(intnumrows)
redim description(intnumrows)
redim username(intnumrows)
redim dateplaced(intnumrows)
redim datedispatched(intnumrows)
redim datearrived(intnumrows)
redim orderid(intnumrows)
intcount = 0
Do while not objrecordset.eof
userid(intcount) = objrecordset("user_id")
quantity(intcount) = objrecordset("quantity")
medicineid(intcount) = objrecordset("medicine_id")
dateplaced(intnumrows) = objrecordset("date_placed")
datedispatched(intnumrows) = objrecordset("date_dispatched")
datearrived(intnumrows) = objrecordset("date_arrived")
orderid(intnumrows) = objrecordset("order_id")
intcount = intcount + 1
objrecordset.movenext
Loop
objrecordset.close
intcount= 0
do while not intcount=intnumrows
strquery="SELECT description FROM medicine WHERE medicine_id ='"&medicineid(intcount)&"'"
objrecordset.open strquery,objdatabase,1,2
description(intcount) = objrecordset("description")
objrecordset.close
intcount = intcount + 1
Loop
intcount = 0
do while not intcount=intnumrows
strquery="SELECT username FROM users WHERE user_id ='"&userid(intcount)&"'"
objrecordset.open strquery,objdatabase,1,2
username(intcount) = objrecordset("username")
objrecordset.close
intcount = intcount + 1
Loop
strorderplaced = "orderplaced.asp?id="&strid&"&who="&strwho
%>
<form method="post" action="orderhistorydone.asp" onsubmit="return FrontPage_Form2_Validator(this)" language="JavaScript" name="FrontPage_Form2">
<p align="left">Please Select a Prescription: <br>
<%
intcount = 0
Do while not intcount = intnumrows
response.write "<br>Medicine: "&description(intcount)&"</td>"
response.write "<br>User ID: "&username(intcount)&"</td>"
response.write "<br>Date Placed: "&dateplaced(intcount)&"</td>"
response.write "<br>Date Dispatched: "&datedispatched(intcount)&"</td>"
response.write "<br>Date Arrived: "&datearrived(intcount)&"</td><br>"
response.write "<input type='radio' value='"&orderid(intcount)&"' name='rdoorderid'><br><br>"
intcount = intcount + 1
Loop
%>
<input type="submit" value="Submit" name="B1"> </p>
</form>


This produces the usrnames and descriptions of what I want fine, but the dates won't display. Am I doing something wrong, and will dates not display like normal text in an array?

lmf232s
06-04-2004, 05:45 PM
What are you storing the date as in the database?

bumcheekcity
06-04-2004, 05:49 PM
Originally posted by lmf232s
What are you storing the date as in the database?

They're stores as dates, not text.

lmf232s
06-04-2004, 05:52 PM
are you by chance using sql server for the DB

bumcheekcity
06-04-2004, 05:54 PM
Originally posted by lmf232s
are you by chance using sql server for the DB

Yup. Ms Sql, SQL Server. That's the one.

lmf232s
06-04-2004, 05:55 PM
hold on, i am going to create some tables and try your code.

bumcheekcity
06-05-2004, 05:46 AM
Can anyone else help?

lmf232s
06-05-2004, 03:00 PM
when you redim you arrays you redim them with the value of
recordcount.
Say
recordcount = 8
so
intnumrows = recordcount(8)

In the first Do loop you set the first 4 variabls to an
index = 0 and the last 4 to an
index = 8.

userid(intcount(0)) = objrecordset("user_id")
quantity(intcount(0)) = objrecordset("quantity")
medicineid(intcount(0)) = objrecordset("medicine_id")
dateplaced(intnumrows(8)) = objrecordset("date_placed")
datedispatched(intnumrows(8)) = objrecordset("date_dispatched")
datearrived(intnumrows(8)) = objrecordset("date_arrived")
orderid(intnumrows(8)) = objrecordset("order_id")

You never increament the last 4 variables so they stay
index = 8 and only get populated with data at an index of
dateplaced(8)
datedispatched(8)
datearrived(8)

Then when you are displaying the data in the last do loop
you set all your variables to an index = 0.
But the dates do not display correctly because you have no values for
dateplaced(1-7)
datedispatched(1-7)
datearrived(1-7)

you only set their values for
index = 8 in the first loop.
dateplaced(8)
datedispatched(8)
datearrived(8)

Their for nothing will display for the dates until your loop hits
intcount = 8

Then it will display the values of
dateplaced(8)
datedispatched(8)
datearrived(8)
This would mean the the first 7 records show up with no dates but the last record displays a date.

Maybe Maybe not
Let Me Know what you think.
Later

bumcheekcity
06-05-2004, 05:53 PM
Thanks man. That worked a treat. MY PAGE WORKS!!! Some of the values are null, so no dates should display, and they work fine too. I can't thank you enough.

lmf232s
06-05-2004, 06:29 PM
Not a problem, glad i could help.
Sorry it took so long, friday, need i say more.

later