Gossamer Forum
Home : General : Databases and SQL :

random display from database

Quote Reply
random display from database
Frown i have problem in randomize...as i am very lousy on it... can someone teach me on it... please...i manage to extract the information and arrange it in the way i want... i have paste my code below...

please help me....

thanx

therapySmile



<%
Dim categoryname,modcat
categoryname = Request.QueryString("categoryname")
modcat = Request.QueryString("modcat")


Dim catArr(3),catID(3)
catArr(0) = "cases"
catArr(1) = "Memory Card"
catArr(2) = "Peripherals"
catArr(3) = "Multifunction Pens"

catID(0) = "1"
catID(1) = "2"
catID(2) = "3"
catID(3) = "5"

call openConn()
Dim strHTML 'holds HTML code to write to page
Dim q 'holds the " character
q = chr(34)


Dim catname, productslist

for j=0 to ubound(catArr)
q = chr(34)
set cmd = server.CreateObject("ADODB.Command")
cmd.ActiveConnection = dbc
' cmd.CommandText = "qryProdsCategory"
' cmd.CommandType = adCmdStoredProc
' set param = cmd.CreateParameter("theCategory",adInteger,adParamInput,4)
' cmd.Parameters.Append(param)
' cmd("theCategory") = cInt(catID((j)))
' Set rs = cmd.Execute

sql = " Select products.*, products.ccategory, categories.catdescription " &_
" FROM categories INNER JOIN products ON categories.categoryID=products.ccategory " &_
" WHERE products.ccategory= " & cInt(catID((j)))

sql = sql & " ORDER BY products.stockquantity DESC, products.preorder ASC "
set rs = server.CreateObject("ADODB.Recordset")
rs.Open sql, dbc, adOpenStatic,adLockReadOnly,adCmdText

' rs.Sort="stockquantity DESC, preorder DESC"

'count number of products in each category
sql = "Select count(preOrder) as cnt FROM products WHERE ccategory="&cInt(j+1)&" and mainproduct='Yes'"
Set rscnt= Server.CreateObject ("ADODB.Recordset")
rscnt.Open sql, dbc, adOpenForwardOnly,adLockReadOnly,adCmdText
prod = rscnt("cnt")
set rscnt = nothing
%>
Subject Author Views Date
Thread random display from database therapy 7077 Jun 19, 2003, 9:50 AM
Thread Re: [therapy] random display from database
Andy 6997 Jun 19, 2003, 9:55 AM
Post Re: [Andy] random display from database
therapy 6856 Jun 19, 2003, 9:59 AM