4
<title>Embperl Examples - DBI access using Dynamic Tables</title>
6
<body background="../images/jazzbkgd.gif">
8
<h1>Embperl Examples - DBI access using Dynamic Tables</h1>
10
You must set the database and table to something which exists on your system<br>
11
Maybe it's necessary to insert a PerlModule DBI into your srm.conf to get this working<br>
17
$DSN = 'dbi:mysql:test' ;
23
$dbh = DBI->connect($DSN) or die "Cannot connect to '$DSN'" ;
25
# prepare the sql select
26
$sth = $dbh -> prepare ("SELECT * from $table") or die "Cannot SELECT from '$table'" ;
29
$sth -> execute or die "Cannot execute SELECT from '$table'";
31
# get the fieldnames for the heading in $head
32
$head = $sth -> {NAME} ;
34
# get the result in $dat
35
$dat = $sth -> fetchall_arrayref ;
40
<tr><th>[+ $head->[$col] +]</th></tr>
41
<tr><td>[+ $dat -> [$row][$col] +]</td></tr>
46
<small>HTML::Embperl (c) 1997-1998 G.Richter</small>