Click to See Complete Forum and Search --> : Loading random images from a database...help quick!


melliekins
12-04-2003, 09:17 AM
it is crunch time...and my ASP project is due on Tuesday (Dec. 9th). We supposedly learned what we needed to complete it, but the book stinks, and our teacher isnt' very helpful.

Our course is somewhere between being an artist and being a programmer...we're neither...I'm a visual person, and the book is just full of exercises to copy. I need practical application...

We need to have a login, connection to a DB...etc etc.

My project is a kind of fan project site...users upload fan art and fan fics....unfortunately...I'm super lost.

We're using Access for the class, and she won't tell me how to put the images in yet, and i don't know how to upload things. I've found a few good links from this site, and I hope they'll help me in that area.

Anyways, the thing with the random images. I want to have a featured item on the main page, so I want to randomly select one from the database. If anyone has anything that could help me with any of this quick....I'd be greatly appreciative.

I put this in general because I'm not sure if it can be done with ASP...or if I'd need to use something else.:confused:


needless to say, this particular teacher is getting a bad evaluation from me.

Thanks,
Melliekins

CTempleman
12-04-2003, 02:02 PM
Well my best guess is you would want to assign an numerical ID to each photo in the database.

Then you can do a row count on the Table that contains the images. Then generate a random number within that range.

To generate a random number you could use:


<%
RANDOMIZE
LowestNumber = 1
HighestNumber = nDBTotal
RandomNumber = INT((HighestNumber-LowestNumber+1)*Rnd+LowestNumber)
%>


Where nDBTotal is the total number of rows in your database. Then you can simply take that random number and use it in a DB call to show that image.

melliekins
12-06-2003, 06:03 PM
thanks, I'll try that...