Wild stab in the dark, but try:
get_latest_comments
my $prefix = 'wp_';
use DBI;
my $dbh = DBI->connect('DBI:mysql:*******', '*******', '*******') || die "Could not connect to database: $DBI::errstr";
my $query = qq|SELECT * FROM ${prefix}comments ORDER BY comment_date DESC LIMIT 10|;
my $sth = $dbh->prepare($query) || die $DBI::errstr;
$sth->execute() || die $DBI::errstr;
my @loop
while (my $hit = $sth->fetchrow_hashref) {
push @loop, $hit;
}
$sth->finish();
$dbh->disconnect();
return { get_latest_comments => \@loop }
}
<%loop get_latest_comments%>
...loop the value stuff here
<%endloop%>
Cheers
Andy (mod)
andy@ultranerds.co.uk
Want to give me something back for my help? Please see my Amazon Wish List
GLinks ULTRA Package | GLinks ULTRA Package PRO
Links SQL Plugins | Website Design and SEO | UltraNerds | ULTRAGLobals Plugin | Pre-Made Template Sets | FREE GLinks Plugins!
get_latest_comments
Code:
sub { my $prefix = 'wp_';
use DBI;
my $dbh = DBI->connect('DBI:mysql:*******', '*******', '*******') || die "Could not connect to database: $DBI::errstr";
my $query = qq|SELECT * FROM ${prefix}comments ORDER BY comment_date DESC LIMIT 10|;
my $sth = $dbh->prepare($query) || die $DBI::errstr;
$sth->execute() || die $DBI::errstr;
my @loop
while (my $hit = $sth->fetchrow_hashref) {
push @loop, $hit;
}
$sth->finish();
$dbh->disconnect();
return { get_latest_comments => \@loop }
}
Code:
<%get_latest_comments%> <%loop get_latest_comments%>
...loop the value stuff here
<%endloop%>
Cheers
Andy (mod)
andy@ultranerds.co.uk
Want to give me something back for my help? Please see my Amazon Wish List
GLinks ULTRA Package | GLinks ULTRA Package PRO
Links SQL Plugins | Website Design and SEO | UltraNerds | ULTRAGLobals Plugin | Pre-Made Template Sets | FREE GLinks Plugins!