<% Set Conn = Server.CreateObject(\"ADODB.Connection\") Conn.Open \"DRIVER={Microsoft Access Driver (*.mdb)}; DBQ=\" & server.mappath(\"dbfil.mdb\") Set rs = Server.CreateObject(\"ADODB.RecordSet\")
strSQL = \"SELECT count(1) as antal FROM random;\" set rs = conn.execute(strSQL) randomize rndNumber = Int(RND * rs(\"antal\")) \'Find et random nummer strSQL = \"SELECT * FROM random;\" set rs = conn.execute(strSQL) rs.move rndNumber response.write rs(\"1\")
strSQL = \"SELECT count(2) as antal FROM random;\" set rs = conn.execute(strSQL) randomize rndNumber = Int(RND * rs(\"antal\")) \'Find et random nummer strSQL = \"SELECT * FROM random;\" set rs = conn.execute(strSQL) rs.move rndNumber response.write rs(\"2\")
strSQL = \"SELECT count(3) as antal FROM random;\" set rs = conn.execute(strSQL) randomize rndNumber = Int(RND * rs(\"antal\")) \'Find et random nummer strSQL = \"SELECT * FROM random;\" set rs = conn.execute(strSQL) rs.move rndNumber response.write rs(\"3\")
Lige det sidste spørgsmål, den tager posterne fra samme ID det skal den ikke :( Og hvis der lad os sige er 50 poster i kolonne 1 30 i 2 og 40 i 3 , så hvis scriptet vælger post 39 får man kun 2 poster :( HELP det sidste
<% Set Conn = Server.CreateObject(\"ADODB.Connection\") Conn.Open \"DRIVER={Microsoft Access Driver (*.mdb)}; DBQ=\" & server.mappath(\"dbfil.mdb\") Set rs = Server.CreateObject(\"ADODB.RecordSet\")
strSQL = \"SELECT count([1]) as antal FROM random;\" set rs = conn.execute(strSQL) randomize rndNumber = Int(RND * rs(\"antal\")) \'Find et random nummer strSQL = \"SELECT * FROM random;\" set rs = conn.execute(strSQL) rs.move rndNumber response.write rs(\"1\")
strSQL = \"SELECT count([2]) as antal FROM random;\" set rs = conn.execute(strSQL) randomize rndNumber = Int(RND * rs(\"antal\")) \'Find et random nummer strSQL = \"SELECT * FROM random;\" set rs = conn.execute(strSQL) rs.move rndNumber response.write rs(\"2\")
strSQL = \"SELECT count([3]) as antal FROM random;\" set rs = conn.execute(strSQL) randomize rndNumber = Int(RND * rs(\"antal\")) \'Find et random nummer strSQL = \"SELECT * FROM random;\" set rs = conn.execute(strSQL) rs.move rndNumber response.write rs(\"3\")
Set Conn = Nothing %>
hvis du ikke vil lave dine kolonne navne om kan man lave det i en for løkke... for i = 1 to 3 ... next ??
for i = 1 to 3 strSQL = \"SELECT count([\"&i&\"]) as antal FROM random;\" set rs = conn.execute(strSQL) randomize rndNumber = Int(RND * rs(\"antal\")) \'Find et random nummer strSQL = \"SELECT * FROM random;\" set rs = conn.execute(strSQL) rs.move rndNumber response.write rs(\"\"&i) next
Denne her hendter du data fra den kolonne som man er kommet til:
for i = 1 to 3 strSQL = \"SELECT count([\"&i&\"]) as antal FROM random;\" set rs = conn.execute(strSQL) randomize timer rndNumber = Int(RND * rs(\"antal\")) \'Find et random nummer strSQL = \"SELECT [\"&i&\"] FROM random;\" set rs = conn.execute(strSQL) rs.move rndNumber response.write rs(\"\"&i) next
<% Set Conn = Server.CreateObject(\"ADODB.Connection\") Conn.Open \"DRIVER={Microsoft Access Driver (*.mdb)}; DBQ=\" & server.mappath(\"dbfil.mdb\") Set rs = Server.CreateObject(\"ADODB.RecordSet\")
strSQL = \"SELECT count([1]) as antal FROM random;\" set rs = conn.execute(strSQL) randomize rndNumber = Int(RND * rs(\"antal\")) \'Find et random nummer strSQL = \"SELECT * FROM random;\" set rs = conn.execute(strSQL) rs.move rndNumber response.write rs(\"1\")
strSQL = \"SELECT count([2]) as antal FROM random;\" set rs = conn.execute(strSQL) randomize rndNumber = Int(RND * rs(\"antal\")) \'Find et random nummer strSQL = \"SELECT * FROM random;\" set rs = conn.execute(strSQL) rs.move rndNumber response.write rs(\"2\")
strSQL = \"SELECT count([3]) as antal FROM random;\" set rs = conn.execute(strSQL) randomize rndNumber = Int(RND * rs(\"antal\")) \'Find et random nummer strSQL = \"SELECT * FROM random;\" set rs = conn.execute(strSQL) rs.move rndNumber response.write rs(\"3\")
Set Conn = Nothing %>
Så jeg takker for indsatsen :9
Synes godt om
Ny brugerNybegynder
Din løsning...
Tilladte BB-code-tags: [b]fed[/b] [i]kursiv[/i] [u]understreget[/u] Web- og emailadresser omdannes automatisk til links. Der sættes "nofollow" på alle links.