sub get_musings_entries { # get musings from MySQL my ($musing_id,$ref_id) = @_; if($ref_id && $ref_id eq 'all') { $sql_stmnt = qq|SELECT musing_id, ref_id, heading,abstract, DATE_FORMAT(entry_date, '%M %e, %Y') FROM musings ORDER BY entry_date DESC|; } elsif($ref_id) { $sql_stmnt = qq|SELECT musing_id, ref_id, heading, abstract, DATE_FORMAT(entry_date, '%M %e, %Y') FROM musings WHERE ref_id = '$ref_id' ORDER BY entry_date DESC LIMIT 10|; } else { $sql_stmnt = qq|SELECT musing_id, ref_id, heading, entry, DATE_FORMAT(entry_date, '%M %e, %Y') FROM musings WHERE musing_id = '$musing_id'|; } $sth = $dbh->prepare($sql_stmnt); $sth->execute(); my $entries = $dbh->selectall_arrayref($sql_stmnt); $sth->finish(); return $entries; }