Gossamer Forum
Home : Products : DBMan : Customization :

show random database?

Quote Reply
show random database?
How can i make a random data show out?
For example, i want to show 10 random data from my Dbman.
Is anyone can make it?

------------------
Stan
wwhoong2@hotmail.com

Quote Reply
Re: show random database? In reply to
I made a little mod that would display all of the records on one page (small database!) in random order. I'm not sure if it would work for you or not.

I made a "dummy" field in each record that is always empty. It's field 1 in my database. When I wanted all of them to show up in random order, I included &random=1 in the URL. In sub query, I added the following lines. (I've kept some of the other lines in there so you can see where I put them. The ones I added are in bold print.)

Code:
LINE: while (<DB> ) {
(/^#/) and next LINE; # Skip comment Lines.
(/^\s*$/) and next LINE; # Skip blank lines.
$line = $_; chomp ($line); # Remove trailing new line.
@values = &split_decode($line);
if ($in{'random'}) {
srand ( );
$values[1]=int(rand(1000)) + 1;
$in{'sb'} = 1;
}


I know this isn't what you want to do, but maybe it will give you an idea of what you do want to do.


------------------
JPD





Quote Reply
Re: show random database? In reply to
it's work
i try to modify the code instead of create a new field
Quote:

if ($in{'random'}) {
srand ( );
$values[0]=int(rand(1000)) + $values[0];
$in{'sb'} = 0;
}
because i use ID as a key field



------------------
Stan
wwhoong2@hotmail.com



[This message has been edited by stanley (edited June 23, 1999).]