|

<%
//OPEN THE CONNECTION
Connatlas = Server.CreateObject("ADODB.Connection")
Connatlas.Open("atlasawning","sa","")
//COUNT HOW MANY QUOTES ARE IN THE DATABASE
strSQL1="SELECT COUNT(*) FROM recipe"
rsrecipe=Connatlas.Execute(strSQL1)
strCount=rsrecipe(0)
//SUBTRACT 1 THE ARRAY USES 0 AS ITS FIRST NUMBER
strRandBanner=strCount-1
//ROLL THE DICE AND GENERATE A RANDOM NUMBER USING THE NUMBER FROM THE COUNT ABOVE
rannum=Math.random()*strRandBanner;
rannum=Math.round(rannum);
strRandBanner=rannum
//SELECT ALL BANNERS AGAIN WHICH MEET THE CRITERIA
strSQL2="SELECT * FROM recipe"
rsrecipe2=Connatlas.Execute(strSQL2)
//CREATE A NEW ARRAY
bannerselect = new Array
i=0
//WRITE THE BANNER_ID'S TO THE ARRAY
while (!rsrecipe2.EOF) {
BannerNum=rsrecipe2('ID')*1
bannerselect[i]=BannerNum
i=i+1
rsrecipe2.MoveNext()
}
TheNumber=bannerselect[strRandBanner]
//PULL THIS BANNER OUT
strSQL3="SELECT * FROM recipe WHERE ID="+TheNumber
rsrecipe3=Connatlas.Execute(strSQL3)
Response.Write ("")
Response.Write ("| ")
Response.Write (""+rsrecipe3('recipename'))
Response.Write (" | ")
Response.Write ("| ")
Response.Write ("Ingredients: "+rsrecipe3('ingredients'))
Response.Write (" | ")
Response.Write ("| ")
Response.Write ("Recipe: "+rsrecipe3('recipe'))
Response.Write (" | ")
%>
|
Click here for a
Printable Page
 |
|