Hi, Anyone know how to adjust this so that the results appear in a random order? is it in the "Order By PostCardID DESC" part? - ..asp
-
-
<!--#Include File="art/dbconnect.asp"-->
-
<%
-
-
-
lngCategoryID=CLng(Request("CategoryID"))
-
If lngCategoryID <> "" And lngCategoryID <> 0 Then
-
-
Set connPostCardSoft=Server.CreateObject("ADODB.Connection")
-
connPostCardSoft.Open PostCardSoftConnectString
-
Set rsCard=Server.CreateObject("ADODB.Recordset")
-
rsCard.CursorLocation = 3
-
SQLQuery="Select PostCardID,DefaultHeadline,CardDescription,DefaultMessage,Author,ThumbnailURL,AdvancedCard,ThumbnailHTML From tblGreetingPostCards Where CategoryID=" & Clng(lngCategoryID) & " Order By PostCardID DESC"
-
rsCard.Open SQLQuery, connPostCardSoft
-
rsCard.PageSize = 200
-
intPageCount = rsCard.PageCount
-
-
If rsCard.EOF=True Then
-
Response.Write "<p>No cards found in database for this category."
-
Response.End
-
End If
-
End If
-
-
'search feature
-
If Request("SearchWord") <> "" Then
-
strWd=Replace(Request("SearchWord"),"'","''")
-
strSQL="Select PostCardID,DefaultHeadline,CardDescription,DefaultMessage,Author, "
-
strSQL=strSQL & " ThumbnailURL,AdvancedCard,ThumbnailHTML From tblGreetingPostCards Where Keywords Like '%" & strWD & "%' OR "
-
strSQL=strSQL & " DefaultHeadline Like '%" & strWD & "%' OR "
-
strSQL=strSQL & " CardDescription Like '%" & strWD & "%' OR "
-
strSQL=strSQL & " Author Like '%" & strWD & "%' OR "
-
strSQL=strSQL & " DefaultMessage Like '%" & strWD & "%' "
-
-
Set connPostCardSoft=Server.CreateObject("ADODB.Connection")
-
connPostCardSoft.Open PostCardSoftConnectString
-
Set rsCard=Server.CreateObject("ADODB.Recordset")
-
rsCard.CursorLocation = 3
-
rsCard.Open strSQL, connPostCardSoft
-
rsCard.PageSize = 200
-
intPageCount = rsCard.PageCount
-
End If
-
-
strAddition="bgcolor=" & Chr(34) & Application("gcp_SearchPageBackgroundColor") & Chr(34)
-
strCategoryBarFontColor=Application("gcp_SearchPageFontBarColor")
-
strCategoryBarColor=Application("gcp_SearchPageBarColor")
-
-
'Retrieve Category Name
-
If lngCategoryID <> "" and lngCategoryID <> 0 Then
-
Set rsCat=connPostCardSoft.Execute("Select * From tblGreetingCategories Where CategoryID=" & Clng(lngCategoryID))
-
strCat="" & rsCat("CategoryName")
-
-
If rsCat("CategoryBackgroundImage")<> "" Then
-
strAddition="background=" & Chr(34) & rsCat("CategoryBackgroundImage") & Chr(34)
-
End If
-
If rsCat("CategoryBackgroundColor")<>"" Then
-
strAddition="bgcolor=" & Chr(34) & rsCat("CategoryBackgroundColor") & Chr(34)
-
End If
-
strCategoryBarFontColor=rsCat("CategoryBarFontColor")
-
strCategoryBarColor=rsCat("CategoryBarColor")
-
FontName=rsCat("FontName")
-
FontColor=rsCat("FontColor")
-
Else
-
strCat="Search results for:" & strWD
-
FontName=Application("gcp_FontName")
-
FontColor=Application("gcp_FontColor")
-
End If
-
-
-
Select Case Request("Action")
-
case " << "
-
intpage = 1
-
case " < "
-
intpage = Request("intpage")-1
-
if intpage < 1 then intpage = 1
-
case " > "
-
intpage = Request("intpage")+1
-
if intpage > intPageCount then intpage = IntPageCount
-
Case " >> "
-
intpage = intPageCount
-
case else
-
intpage = 1
-
If Request.QueryString("intpage") <> "" Then
-
intpage=Request.QueryString("intpage")
-
End If
-
end select
-
-
-
-
%>
-
-
-
.. asp
Thanks
Richard
3 1410
I don't think sql can be done random. You could try putting all the results in a set of arrays, and then accessing them randomly... Let me know if this helps.
Jared
Thanks for replying,
The answer I found was that this works. Changing this string - ..code asp
-
-
SQLQuery="Select PostCardID,DefaultHeadline,CardDescription,DefaultMessage,Author,ThumbnailURL,AdvancedCard,ThumbnailHTML,Rnd([PostCardID]) From tblGreetingPostCards Where CategoryID=" & Clng(lngCategoryID) & " Order By Rnd([PostCardID])"
-
-
..code asp
Thanks
Richard
Thanks for replying,
The answer I found was that this works. Changing this string - ..code asp
-
-
SQLQuery="Select PostCardID,DefaultHeadline,CardDescription,DefaultMessage,Author,ThumbnailURL,AdvancedCard,ThumbnailHTML,Rnd([PostCardID]) From tblGreetingPostCards Where CategoryID=" & Clng(lngCategoryID) & " Order By Rnd([PostCardID])"
-
-
..code asp
Thanks
Richard
thanks for posting your solution! It looks like I have more to learn.
Jared
Sign in to post your reply or Sign up for a free account.
Similar topics
by: Ben Pfaff |
last post by:
One issue that comes up fairly often around here is the poor
quality of the pseudo-random number generators supplied with many
C implementations. As a result, we have to recommend things like...
|
by: Michael B Allen |
last post by:
Someone once posted the following macro on clc:
#define randint(a,b) (a)+(((b)-(a)+1)*(float)rand()/RAND_MAX)
Unfortunately it's flawed. If rand() returns RAND_MAX the result can be
one larger...
|
by: Papajo |
last post by:
Hi, This script will write a random number into a document write tag,
I've been trying to get it to write into a input form box outside the
javascript, any help is appreciated. Thanks Joe
...
|
by: Jim Michaels |
last post by:
I need to generate 2 random numbers in rapid sequence from either PHP or
mysql.
I have not been able to do either. I get the same number back several times
from PHP's mt_rand() and from mysql's...
|
by: Pascal |
last post by:
hello and soory for my english
here is the query :"how to split a string in a random way"
I try my first shot in vb 2005 express and would like to split a number in
several pieces in a random way...
|
by: FrankEBailey |
last post by:
I'm not sure if this is a completely dumb question, but please humor me
:) I have a table of records, called Records, each of which has a
Category_ID that places it in a specific category; the...
|
by: FAQ server |
last post by:
-----------------------------------------------------------------------
FAQ Topic - How do I generate a random integer from 1 to N?...
|
by: tshad |
last post by:
I have a page that I am getting a username and password as a random number
(2 letters, one number and 4 more letters)
I have 2 functions I call:
*************************************************...
|
by: Army1987 |
last post by:
Is there anything wrong with this program? It seems to behave
strangely if I give stdin EOF when asked for the character set...
/* BEGIN pwdgen.c */
#include <stdio.h>
#include "random.h"...
|
by: caca |
last post by:
Hello,
This is a question for the best method (in terms of performance
only) to choose a random element from a list among those that satisfy
a certain property.
This is the setting: I need to...
|
by: Faith0G |
last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
|
by: isladogs |
last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM).
In this session, we are pleased to welcome former...
|
by: ryjfgjl |
last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
|
by: aa123db |
last post by:
Variable and constants
Use var or let for variables and const fror constants.
Var foo ='bar';
Let foo ='bar';const baz ='bar';
Functions
function $name$ ($parameters$) {
}
...
|
by: ryjfgjl |
last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
|
by: ryjfgjl |
last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
|
by: BarryA |
last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
|
by: Sonnysonu |
last post by:
This is the data of csv file
1 2 3
1 2 3
1 2 3
1 2 3
2 3
2 3
3
the lengths should be different i have to store the data by column-wise with in the specific length.
suppose the i have to...
|
by: Hystou |
last post by:
There are some requirements for setting up RAID:
1. The motherboard and BIOS support RAID configuration.
2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
| |