Limiting Results

Results 1 to 5 of 5

Thread: Limiting Results

  1. #1
    Join Date
    Dec 1969
    Posts
    146

    Default Limiting Results

    Hi, I am working on a script where I want to list the site. I can&#039t seem to get it to limit the results. If you know how could you please tell me. My code is below<BR><BR><BR><BR><BR><BR>&#060;%<BR>Set MyConn = Server.CreateObject("ADODB.Connection")<BR>MyConn. Open "FILEDSN=c:dsnMyTable_dsn.dsn"<BR>%&#062;<BR><BR>& #060;HTML&#062;<BR>&#060;HEAD&#062;<BR>&#060;TITLE &#062;Welcome To Tiberian Twilight Nation - All things TT&#060;/TITLE&#062;<BR>&#060;style&#062;<BR>&#060;!--<BR>A:link {text-decoration: none}<BR>A:visited {text-decoration: none}<BR>A:active {text-decoration: none}<BR>A:hover {color:#646464}<BR>{ font-family: OCR A Extended }<BR>--&#062;<BR>&#060;/style&#062;<BR><BR>&#060;META NAME="resource-type" CONTENT="document"&#062;<BR>&#060;META NAME="generator" CONTENT="Russell Proud"&#062;<BR>&#060;META NAME="author" CONTENT="Lightning"&#062;<BR>&#060;META NAME="description" CONTENT="The Tiberian Twilight Nation, your 1 stop resource for all things Tiberian Twilight"&#062;<BR>&#060;META NAME="keywords" CONTENT="command, and, conquer, tiberian, twilight, red, alert, westwood, lightning, flash, tiberium, sun, c&c, gold, nation, tt, tanks, guns, infantry, orca, gdi, nod, power, plant, games, rts, real, time, strategy, covert, operations, competitions, new, game, zone, tib, maps, ccmap, units, virgin, ea, sierra, electronic, arts, interactive"&#062;<BR>&#060;META NAME="distribution" CONTENT="Global"&#062;<BR><BR><BR><BR><BR>&#060;/HEAD&#062;<BR>&#060;BODY BGCOLOR="#000000" TEXT="#646464" VLINK="#FF9800" ALINK="#FF9800" LINK="#FF9800" LANG="en-AUS"&#062;<BR><BR><BR><BR>&#060;FONT FACE="Copperplate Gothic Bold" SIZE="+2"&#062;&#060;CENTER&#062;TOP 100 GAMING SITES&#060;/CENTER&#062;&#060;/FONT&#062;&#060;P&#062;<BR><BR><BR><BR><BR>&#060;% <BR>SQL_query = "SELECT * FROM topsites"<BR>Set RS = MyConn.Execute(SQL_query)<BR><BR>%&#062; <BR>&#060;CENTER&#062;&#060;TABLE WIDTH="650" BORDER="1" BORDERCOLOR="Navy"&#062;<BR>&#060;%<BR>WHILE NOT RS.EOF<BR>%&#062; <BR><BR> &#060;TR&#062;<BR> &#060;TD&#062;&#060;CENTER&#062;&#060;%=RS("Name") %&#062;&#060;/CENTER&#062;&#060;/TD&#062;<BR><BR> &#060;TD&#062;&#060;CENTER&#062;&#060;%=RS("Votes" )%&#062;&#060;/CENTER&#062;&#060;/TD&#062;<BR> &#060;TD&#062;&#060;A HREF="/topsites/info.asp?ID=&#060;%=RS("ID")%&#062;" Target="_blank"&#062;&#060;IMG SRC="images/info.gif" BORDER="0"&#062;&#060;/A&#062;&#060;/TD&#062;<BR> &#060;/TR&#062;<BR><BR>&#060;%<BR>RS.MoveNext<BR>Wend<BR> %&#062;<BR>&#060;/TABLE&#062;&#060;/CENTER&#062;<BR><BR>&#060;/FONT&#062;<BR>&#060;/TD&#062;<BR> <BR>

  2. #2
    Join Date
    Dec 1969
    Posts
    155

    Default RE: Limiting Results

    What do you mean by limiting the results?<BR>The Select * FROM Wherever is going to<BR>select everything I believe. Do you want to limit the number<BR>of sites it returns? For example to return 20<BR>FOR i = 0 to 20 <BR>response.write(sites(i))<BR>NEXT<BR><BR>Litt le more info please<BR><BR>Rob Taylor<BR>taylo@bannerclass.com<BR>www.cartography today.com<BR>Stop by and vote!!!!

  3. #3
    Join Date
    Dec 1969
    Posts
    146

    Default RE: Limiting Results

    Sorry about that, I mean limiting the number of results it show on the page. Like you said. I wanted to limit them to 20, could you please tell me how.

  4. #4
    Peter Cooper Guest

    Default RE: Limiting Results

    You will need to output the information using a for loop. i.e.<BR><BR>for i = start to start + 20<BR> for NumberOfFieldsInTable = 0 to 8<BR> response.write MyRS(NumberOfFieldsInTable)<BR> next<BR> MyRs.MoveNext<BR>next<BR><BR>But then need to pass in the [start] variable as the string you want to start at.<BR><BR>Pete<BR><BR>peter@zore.com


  5. #5
    Corey Plover Guest

    Default RE: Limiting Results

    If you wish to select the top, say 10, sites, where the database entries are sorted by some value (such as a rating value), you can try to change your query to something such as:<BR><BR>SQL_Query = "SELECT TOP 10 * FROM topsites ORDER BY rating DESC"<BR>SET RS = MyConn.Execute(SQL_Query)<BR><BR>where topsites is your table name;<BR> rating is your field value;<BR> DESC / ASC for whether sorted descending or ascending<BR>

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •