Assumning you have SSI setup and working, you simply write CGI scripts that
query the database and create HTML data islands.  These are then included in
your documents using SSI directives.

In the HTML document in which you wish to embed the data, include an SSI
directive pointing to the CGI script that queries the database - the SSI
syntax varies for different http servers.

Apache: <!--#include virtual="/cgi-bin/contacts.cgi"-->
IIS: <!--#exec cgi="/cgi-bin/contacts.cgi"-->

This assumes you already have SSI setup and working.

I've attached a simple SSI, DBI, CGI script that genarates a simple HTML
table.

Let me know how you get on.

--
  Simon Oliver

#!/usr/bin/perl -Tw
use strict;
use DBI;
print ("Content-Type: text/html\n\n");

my ($dbd, $dsn, $dbh, $sth);           
my ($id, $email, $name);

$dbd = 'ODBC'; 
$dsn = 'contact';
$dbh = DBI->connect("dbi:$dbd:$dsn");

$sth = $dbh->prepare('SELECT contact_id, email, name from contact'); 
$sth->execute;
$sth->bind_columns(\($id, $email, $name));

print qq(<TABLE>);
print << "EOHTML" while ($sth->fetch);
<TR>
    <TD><A HREF="mailto:$email";><IMG SRC="/images/email.gif" BORDER="0"
ALT="email"></A></TD>
    <TD><A HREF="/cgi-bin/details.cgi?id=$id">$name</A></FONT></CODE></TD>
</TR>
EOHTML
print "</TABLE>";

$dbh->disconnect;

Reply via email to