Variables in DB-Query - Random Records (Full Version)

All Forums >> [Web Development] >> ASP and Database



Message


Matth -> 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 -> 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!





Matth -> 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!





Page: [1]

Valid CSS!




Forum Software © ASPPlayground.NET Advanced Edition 2.4.5 ANSI
0.046875