|
|
|||||||||
|
|||||||||
|
|||||||||
| |
||
| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
#1
|
|||
|
|||
|
random display of information from databases
can someone help me... this is my code but whenever i clicked refresh my item seem to become lesser...<br><br> 'make it random<br> Dim x, recordsCount<br> Randomize<br> 'first count how many records we have:<br> recordsCount=0<br> Do Until rs.EOF<br> recordsCount=recordsCount+1 : rs.MoveNext<br> Loop<br> rs.Close<br> 'now execute again:<br> set rs = cmd.Execute<br> 'finally make it really random<br> For x=1 To CLng(recordsCount * Rnd)<br> rs.MoveNext<br> Next
|
|
#2
|
|||
|
|||
|
your number will be between 0 and 3. Of course you tend to have fewer records displayed because let's say random number is 1.4556
in this case it'd display record 1 and that's it. Code:
set rs = con.Execute (strSQL)
'finally make it really random
response.write "< br>"
blah = cint(recordsCount * Rnd)
for l=1 to 20
response.write "Random =" & blah & "< br>"
For x=1 To (blah)
response.write RS("id_no")
rs.MoveNext
Next
blah = cint(recordsCount * Rnd)
Rs.movefirst
response.write "< br>< br>"
Next
run this to get a better idea of what's going on. |
![]() |
| Viewing: ASP Free Forums > Database > Microsoft SQL Server > random display of information from databases |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|