Skeeter87
02-26-2005, 01:58 PM
Im using these lines to retrieve records from my database.. It works fine but I want to display 1 RANDOM record at a time which meets all criteria. To be honoust I dont have a clue :confused: how to display 1 random record every time..but I'm sure you can help me !?
#!/usr/bin/perl
use CGI;
$q=new CGI;
print "Content-Type: text/html\n\n";
$name = "goods";
die "Missing DBM name.\n" unless $name;
dbmopen(%map,$name,0666);
$rec = 0;
while (($key,$val)=each(%map)) {
($item1,$item2,$item3,$item4) = split("\t",$val);
if ($item2 eq "Radio") {
## check $item3 for "philips"
print qq{$item2<br>};
}}
dbmclose(%map);
exit;
#!/usr/bin/perl
use CGI;
$q=new CGI;
print "Content-Type: text/html\n\n";
$name = "goods";
die "Missing DBM name.\n" unless $name;
dbmopen(%map,$name,0666);
$rec = 0;
while (($key,$val)=each(%map)) {
($item1,$item2,$item3,$item4) = split("\t",$val);
if ($item2 eq "Radio") {
## check $item3 for "philips"
print qq{$item2<br>};
}}
dbmclose(%map);
exit;