my $max_id = sql_fetch("select max(id) from beitraege where email=?", $email); my $captcha_id = $max_id % scalar @capchas;