Gossamer Forum
Home : Products : DBMan : Customization :

How can I include a random routine for display the results

Quote Reply
How can I include a random routine for display the results
Hello,

in html.pl I'm using the following sub for display the results in short form:

###################
# sub html_record_short
###################

sub html_record_short {

my (%rec) = @_; # Load any defaults to put in the VALUE field.
($db_auto_generate and print &build_html_record(%rec) and return);
my $font_color = 'font face="arial" size=1 color=#003399';
my $font = 'font face="arial" size=1 ';

print qq|
td bgcolor=#F0CC91 font face="verdana, arial" size=1
(a href="$db_script_link_url&ID=$rec{'ID'}&format=long&view_records=1")Details(/a)(/font)(/td)
(td bgcolor=#F4F4F4)
...and so on...

No when I submit "list all" the results always coming in the same sorting.

How can I include a random-routine like this:

sub mix {
my $array = shift;
my $i;
for ($i = @array; --$i Wink {
my $j = int rand ($i+1);
next if $i == $j;
@array[$i,$j] = @$array[$j, $i];
}
}

...and so on...

any hints?

thanks,

HP
Quote Reply
Re: How can I include a random routine for display the results In reply to
to JPDeni:

I know your "dummy"-solution, it works fine :-)

maybe there is another solution without
a dummyfield

regards,

HP
Quote Reply
Re: How can I include a random routine for display the results In reply to
I don't know of one. The problem is that you have to create random values for a field. But you probably won't know what those values are. For example, you may have a counter for your key field, but there would be gaps in the counter if any records are deleted.


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