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 1420 jhardman 3,406
Recognized Expert Specialist
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
jhardman 3,406
Recognized Expert Specialist
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
using the high-order bits returned by rand() instead of the
low-order bits, avoiding using rand() for anything that wants
decently random numbers, not using rand() if you want more than
approx. UINT_MAX total different sequences, and so on.
So I...
|
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 than b.
So can someone provide a *proper* macro (or function) that returns a
random integer between (actually in) a range of values? For example
randint(0, 999) could return:
|
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
http://web2jo.com/Work/Random_Temp.html
|
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 RAND().
any ideas?
I suppose I could use the current rancom number as the seed for the next
random number. but would that really work?
|
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 without success.
for example if the number is 123 456 : i would like to have some random
strings like theese :
(12 * 10 000) + (345 * 10) + (6*1)
or
(123*1 000)+(4*100)+(5*10)+(6*1)
etc...
| |
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 details of the
categories are stored in another table called Category. What I need to
do is retrieve a recordset that contains one record from each category,
but where the records that are retrieved are random. I know how to
retrieve one or more...
|
by: FAQ server |
last post by:
-----------------------------------------------------------------------
FAQ Topic - How do I generate a random integer from 1 to N?
-----------------------------------------------------------------------
function Random(x) { return Math.floor(x*Math.random()) }
gives a random integer in the range from 0 to x-1 inclusive; use
« Random(N)+1 » for 1 to N where N>2.
...
|
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:
*************************************************
Function RandomString(size as integer, lowerCase as boolean) as string
Dim builder as StringBuilder = new StringBuilder()
Dim random as Random = new Random()
Dim i as integer
dim ch as char
|
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"
#include <stdlib.h>
#include <string.h>
#define MAX_PWD_LEN 128
|
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 pick from a list a random element
that satisfies a given property. All or none of the elements may have
the property. Most of the time, many of the elements will satisfy the
property, and the property is a bit expensive to evaluate. Chance of...
|
by: marktang |
last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look !
Part I. Meaning of...
| |
by: Hystou |
last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it.
First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
|
by: jinu1996 |
last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth.
The Art of Business Website Design
Your website is...
|
by: isladogs |
last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 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 a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules.
He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms.
Adolph will...
|
by: conductexam |
last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one.
At the time of converting from word file to html my equations which are in the word document file was convert into image.
Globals.ThisAddIn.Application.ActiveDocument.Select();...
|
by: TSSRALBI |
last post by:
Hello
I'm a network technician in training and I need your help.
I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs.
The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols.
I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
|
by: 6302768590 |
last post by:
Hai team
i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
| |
by: muto222 |
last post by:
How can i add a mobile payment intergratation into php mysql website.
|
by: bsmnconsultancy |
last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...
| |