Web Wiz - Green Windows Web Hosting

  New Posts New Posts RSS Feed - Mod Req : Show 5 Random Topic ...
  FAQ FAQ  Forum Search   Events   Register Register  Login Login

Mod Req : Show 5 Random Topic ...

 Post Reply Post Reply
Author
miladanimator View Drop Down
Groupie
Groupie
Avatar

Joined: 24 July 2005
Location: United States
Status: Offline
Points: 156
Post Options Post Options   Thanks (0) Thanks(0)   Quote miladanimator Quote  Post ReplyReply Direct Link To This Post Topic: Mod Req : Show 5 Random Topic ...
    Posted: 25 June 2006 at 1:32pm
I need a mod to show 5 (x) random topic in default.asp file ...

any one have a code to show random datas from database ?
Back to Top
chicken View Drop Down
Groupie
Groupie
Avatar

Joined: 22 October 2005
Location: United Kingdom
Status: Offline
Points: 78
Post Options Post Options   Thanks (0) Thanks(0)   Quote chicken Quote  Post ReplyReply Direct Link To This Post Posted: 06 July 2006 at 12:49pm
i would like this awell
Back to Top
chicken View Drop Down
Groupie
Groupie
Avatar

Joined: 22 October 2005
Location: United Kingdom
Status: Offline
Points: 78
Post Options Post Options   Thanks (0) Thanks(0)   Quote chicken Quote  Post ReplyReply Direct Link To This Post Posted: 21 December 2006 at 12:13pm
anyone?
Back to Top
MrMellie View Drop Down
Senior Member
Senior Member
Avatar

Joined: 12 December 2006
Location: United Kingdom
Status: Offline
Points: 251
Post Options Post Options   Thanks (0) Thanks(0)   Quote MrMellie Quote  Post ReplyReply Direct Link To This Post Posted: 21 December 2006 at 1:19pm
I've got top 8 random picture selections on my Photo Album mod, I'll go and check the code (been 2 years since I done it), the same principle should work.
Back to Top
chicken View Drop Down
Groupie
Groupie
Avatar

Joined: 22 October 2005
Location: United Kingdom
Status: Offline
Points: 78
Post Options Post Options   Thanks (0) Thanks(0)   Quote chicken Quote  Post ReplyReply Direct Link To This Post Posted: 21 December 2006 at 1:41pm
thanks :)
Back to Top
MrMellie View Drop Down
Senior Member
Senior Member
Avatar

Joined: 12 December 2006
Location: United Kingdom
Status: Offline
Points: 251
Post Options Post Options   Thanks (0) Thanks(0)   Quote MrMellie Quote  Post ReplyReply Direct Link To This Post Posted: 21 December 2006 at 2:21pm
Ok, this is lifted straight out of my MOD, so you'll need to adapt it to read the topic ID's from the topics table etc.

     strSQL="SELECT MAX(IMAGEID) AS MAXID FROM PA_IMAGES" 

     rs.Open strSQL, dbCon, adOpenStatic ,adLockReadOnly
     nMax = rs("maxid")
     rs.Close
     nMin = 1
     rs.Open "SELECT IMAGEID FROM PA_IMAGES", dbCon,adOpenStatic

     RndCnt=1
     do while RndCnt < 9
          Randomize     
          nRnd = Int((nMax - nMin + 1)*Rnd() + nMin)
          rs.MoveFirst
          rs.Find("IMAGEID=")&nRnd
          if rs.EOF = false then
               if instr(strRand,cstr(nRnd))=0 then
                    strRand=strRand & cstr(nRnd) & ","
                    RndCnt=RndCnt+1
               end if
          end if
     loop
     strRand=left(strRand,len(strRand)-1)
     rs.Close

     rs.Open "SELECT I.IMAGEID,I.IMAGE,I.APPROVED,M_NAME FROM PA_IMAGES I,PA_USERS U WHERE I.MEMBER_ID=U.MEMBER_ID AND I.IMAGEID IN(" &strRand &")", dbCon, adOpenStatic ,adLockReadOnly
          
So, what's happening is, you first get the maximum value of ID in the table, then loop though 8 times (change this to 5 for your mod) and generate a random integer between 1 and this max ID. This gets concatenated into a string that is then used in the last query to fetch the ID's from the Topic table that are in the list stored in the string. Hope that makes sense!!
Back to Top
chicken View Drop Down
Groupie
Groupie
Avatar

Joined: 22 October 2005
Location: United Kingdom
Status: Offline
Points: 78
Post Options Post Options   Thanks (0) Thanks(0)   Quote chicken Quote  Post ReplyReply Direct Link To This Post Posted: 22 December 2006 at 6:32pm
ok cool thanks i will try and see what i can do
Back to Top
 Post Reply Post Reply

Forum Jump Forum Permissions View Drop Down

Forum Software by Web Wiz Forums® version 12.08
Copyright ©2001-2026 Web Wiz Ltd.


Become a Fan on Facebook Follow us on X Connect with us on LinkedIn Web Wiz Blogs
About Web Wiz | Contact Web Wiz | Terms & Conditions | Cookies | Privacy Notice

Web Wiz is the trading name of Web Wiz Ltd. Company registration No. 05977755. Registered in England and Wales.
Registered office: Web Wiz Ltd, Unit 18, The Glenmore Centre, Fancy Road, Poole, Dorset, BH12 4FB, UK.

Prices exclude VAT at 20% unless otherwise stated. VAT No. GB988999105 - $, € prices shown as a guideline only.

Copyright ©2001-2026 Web Wiz Ltd. All rights reserved.