navigation
a webmaster learning community
     Home    Register     Search      Help      Login    
Sponsors

Shopping Cart Software
Ecommerce software integrated into Frontpage, Dreamweaver and Golive templates. No monthly fees and available in ASP and PHP versions.

Website Templates
We also have a wide selection of Dreamweaver, Expression Web and Frontpage templates as well as webmaster tools and CSS layouts.

Frontpage website templates
Creative Website Templates for FrontPage, Dreamweaver, Flash, SwishMax

Search Forums
 

Advanced search
Recent Posts

 Todays Posts
 Most Active posts
 Posts since last visit
 My Recent Posts
 Mark posts read

Microsoft MVP

 

Variables in DB-Query - Random Records

 
View related threads: (in this forum | in all forums)

Logged in as: Guest
Users viewing this topic: none
Printable Version 

All Forums >> Web Development >> ASP and Database >> Variables in DB-Query - Random Records
Page: [1]
 
Matth

 

Posts: 36
From: Zurich, Switzerland
Status: offline

 
Variables in DB-Query - Random Records - 3/17/2001 20:32:00   
Hi there

I've been browsing and trying but couldn't find a solution.

I have some twelve records (will slowly increase over time) and I would like to pull out 4 to 5 random records and display a field.

First I have setup the query with FP2K and just got all records. Then I limited the query to only get a couple of rows back, using the WHERE INDEX IN (X, Y, Z). This also worked fine.

'SELECT * FROM "table_name" where index in (1,3,4,7,11)'

Then I've created a variable that should replace the '(X, Y, Z)' in my query, which also worked fine. See the code below:

<%
Dim marray

Randomize Timer
marray = Int(RND * 12) & ", "
Randomize Timer
marray = marray & Int(RND * 12) & ", "
Randomize Timer
marray = marray & Int(RND * 12) & ", "
Randomize Timer
marray = marray & Int(RND * 12) & ", "
Randomize Timer
marray = marray & Int(RND * 12) & ", "
Randomize Timer
marray = marray & Int(RND * 12) & ", "
Randomize Timer
marray = marray & Int(RND * 12)

response.write marray
%>

But now I'm completely lost. I have no clue how I could replace the constant values with my variable 'marray' in the query. I've managed to use a search form and fill the form field with the variable. But then, I always have to click first on the 'Submit' button before the results are shown.

I'm using the FP Database wizard, cos I'm not too good at .asp and the best I can do is to tweak around some existing code.

I'd highly appreciate some help. Thanks a lot in advance for any hint.

Spooky

 

Posts: 26599
Joined: 11/11/1998
From: Middle Earth
Status: offline

 
RE: Variables in DB-Query - Random Records - 3/18/2001 20:23:00   
Have a look at the drw diet and this will allow you to use the variable.

Currently you can only input the variable via a form.
The diet changes it to asp and you can use :

'SELECT * FROM "table_name" where index in ("&marray"&)'

------------------
Spooky
"I am Spooky of Borg. Prepare to be assimilated, babycakes!"
Subscribe to OutFront News
Database / DRW Q & A
The Spooky Login!


(in reply to Matth)
Matth

 

Posts: 36
From: Zurich, Switzerland
Status: offline

 
RE: Variables in DB-Query - Random Records - 3/18/2001 17:19:00   
Spooky, you're the king.

It works and is just great

I'm not yet so happy with my random function, but I keep on working on that ...

Thanks again!


(in reply to Matth)
Page:   [1]

All Forums >> Web Development >> ASP and Database >> Variables in DB-Query - Random Records
Page: [1]
Jump to: 1





New Messages No New Messages
Hot Topic w/ New Messages Hot Topic w/o New Messages
Locked w/ New Messages Locked w/o New Messages
 Post New Thread
 Reply to Message
 Post New Poll
 Submit Vote
 Delete My Own Post
 Delete My Own Thread
 Rate Posts