Database Reference
In-Depth Information
# No encoding is done because the chapter numbers are digits and don't
# need it.
sub
get_chapter_list
{
my
(
$dbh
,
$cnum
)
=
@_
;
my
$nav_index
;
my
$ref
=
$dbh
->
selectcol_arrayref
(
"SELECT DISTINCT cnum FROM kjv
WHERE bname = 'Esther' ORDER BY cnum"
);
foreach
my
$cur_cnum
(
@
{
$ref
})
{
my
$link
=
url
()
.
"?chapter=$cur_cnum"
;
my
$label
=
"Chapter $cur_cnum"
;
$nav_index
.=
br
()
if
$nav_index
;
# separate entries by <br>
# use static bold text if entry is for current chapter,
# use a hyperlink otherwise
$nav_index
.=
(
$cur_cnum
==
$cnum
?
strong
(
$label
)
:
a
({
-
href
=>
$link
},
$label
));
}
return
$nav_index
;
}
# Get the list of verses for a given chapter. If there are none, the
# chapter number was invalid, but handle that case sensibly.
sub
get_verses
{
my
(
$dbh
,
$cnum
)
=
@_
;
my
$ref
=
$dbh
->
selectall_arrayref
(
"SELECT vnum, vtext FROM kjv
WHERE bname = 'Esther' AND cnum = ?"
,
undef
,
$cnum
);
my
$verses
=
""
;
foreach
my
$row_ref
(
@
{
$ref
})
{
$verses
.=
p
(
escapeHTML
(
"$row_ref->[0]. $row_ref->[1]"
));
}
return
$verses
eq
""
# no verses?
?
p
(
"No verses in chapter $cnum were found."
)
:
p
(
"Chapter $cnum:"
)
.
$verses
;
}
my
$title
=
"The Topic of Esther"
;
my
$page
=
header
()
.
start_html
(
-
title
=>
$title
);
my
$dbh
=
Cookbook::
connect
();