#!/usr/bin/perl /usr/local/bin/asp-perl
<%
use LinkDB;
my ($id, $url, $name, $description);
# Set up to fetch the rows of links from the db
my $sth = $db->prepare("SELECT * FROM link");
$sth->execute;
$sth->bind_columns(\$id, \$url, \$name, \$description);
%>
List of links:
| Name |
Description |
Action |
<% while ($sth->fetch) { %>
| <%=$name%> |
<%
my $desc = LinkDB::unquote($description);
$Response->Include(\$desc); %> |
Edit
| Delete
|
<% } %>
[ Add a link ]
| Category |
Description |
Action |
<%
# Set up to fetch the rows of categories from the db
my $sth = $db->prepare("SELECT * FROM category");
$sth->execute;
$sth->bind_columns(\$id, \$name, \$description);
while($sth->fetch)
{ %>
| <%=$name%> |
<%=$description%> |
Edit
| Delete
|
<% }
%>
[ Add a category ]
<%
my $cat_st = $db->prepare("SELECT * FROM category ORDER BY name");
$cat_st->execute;
while(my $cat = $cat_st->fetchrow_hashref)
{
print "$cat->{name}
\n";
my $link_st = $db->prepare("
SELECT * FROM link, link_to_category
WHERE id=link_id AND category_id=$cat->{id}
ORDER BY name
");
$link_st->execute;
while(my $link = $link_st->fetchrow_hashref)
{
print "\n";
}
}
%>