use Tk;
use Tk::HList;
use DBI;
my ($dbh, $sth);
$dbh = DBI->connect ("DBI:mysql:host=192.168.0.6;database=cdmcrm",
"ich", "geheim", {PrintError => 0, RaiseError => 1});
$sth = $dbh->prepare ("SELECT Nachname, Vorname, Telefon, Email FROM mitarbeiter WHERE Nachname LIKE 'H%'");
$sth->execute();
# Ende der Datenbankinitialisierung
$top = new MainWindow;
$hlist = $top->Scrolled("HList",
-header => 1,
-columns => 4,
-scrollbars => 'osoe',
-width => 70,
-selectbackground => 'SeaGreen3',
)->pack(-expand => 1, -fill => 'both');
$hlist->header('create', 0, -text => 'Nachname');
$hlist->header('create', 1, -text => 'Vorname');
$hlist->header('create', 2, -text => 'Telefon');
$hlist->header('create', 3, -text => 'Email');
&dbget();
MainLoop;
sub dbget {
my @zeile;
my $i=0;
while (@zeile = $sth->fetchrow_array()) {
$hlist->add($i);
$hlist->itemCreate($i, 0, -text => "$zeile[0]");
$hlist->itemCreate($i, 1, -text => "$zeile[1]");
$hlist->itemCreate($i, 2, -text => "$zeile[2]");
$hlist->itemCreate($i, 3, -text => "$zeile[3]");
$i++;
}
$sth->finish();
$dbh->disconnect()
}