i am back. here is code borrow from random link globe.
Random_category => sub {
my $tags = shift;
my $category_db = $DB->table('category');
my $cat_id = $tags->{Random_CatID};
my $limit = $tags->{Random_Limit} || 1;
my (@output, $sth);
$category_db->select_options ('ORDER BY RAND()', "LIMIT $limit");
if ($cat_id) {
$sth = $category_db->select ( { ID => $cat_id });
}
else {
$sth = $category_db->select;
}while (my $hash = $sth->fetchrow_hashref) {
push @output, $hash;
}return { Random_Loop => \@output }
}
it comes to a bit trouble part. how to show the a links belongs to that category?
Thanks
Random_category => sub {
my $tags = shift;
my $category_db = $DB->table('category');
my $cat_id = $tags->{Random_CatID};
my $limit = $tags->{Random_Limit} || 1;
my (@output, $sth);
$category_db->select_options ('ORDER BY RAND()', "LIMIT $limit");
if ($cat_id) {
$sth = $category_db->select ( { ID => $cat_id });
}
else {
$sth = $category_db->select;
}while (my $hash = $sth->fetchrow_hashref) {
push @output, $hash;
}return { Random_Loop => \@output }
}
it comes to a bit trouble part. how to show the a links belongs to that category?
Thanks