you aren't showing code that fetches the result of get the random record. are you fetching it? what do you get? any errors? what do you mean 'it does nothing? it looks like you want to requery with select where num = $numbers[$r_num] .. that way you would be using the value from the first query as your search criteria.
On Friday, March 29, 2002, at 05:35 PM, FLAHERTY, JIM-CONT wrote: > I am lost . I have this quiz program , It prints and grades the quiz . now > the managers want to make it put out random tests > > My Code : > > > > $dbh =DBI ->connect($data_source, $username, $password) or die "cant > connect > to $data_source : my $dbh-> errstr\n"; > my $sth1 = $dbh -> prepare("select num from tests where subject = > '$test' > "); > > $sth1 -> execute or die " unable to execute query "; > #$sth1 -> finish; > > > my $array_ref = $sth1 -> fetchall_arrayref(); > $count = 0; > foreach $row(@$array_ref){ > > my($num) = @$row; > @numbers[$count] = $num; > $count++; > } > > $r_num = rand(@numbers); > > > > > > > > > $dbh =DBI ->connect($data_source, $username, $password) or die "cant > connect > to > $data_source : my $dbh-> errstr\n"; > my $sth1 = $dbh -> prepare("select * from tests where num = '$r_num' "); > $sth1 -> execute or die " unable to execute query "; > #$sth1 -> finish; > > > > > > __________________________________ > > I figured to query on the test question numbers ( the are unique) then > randomize the numbers. This table has other test questions as well. When > I > randomize the NUM s returns from the query, I thought I would re-query for > the whole record where num = randomize number. I dont know if that is the > best way to go . > > but I am now stuck , its not randomizing . In fact its not doing anything > > help ! > > Jim > > > > -- > To unsubscribe, e-mail: [EMAIL PROTECTED] > For additional commands, e-mail: [EMAIL PROTECTED] >