#!/usr/bin/perl use DBI; use strict; use CGI qw/:standard/; print header(-type => 'text/xml'); my $dbh = DBI->connect( 'dbi:mysql:database=mapsbookex;host=db.maps.mcslp.com', 'mapsbookex', 'examples', ); if (!defined($dbh)) { die "Couldn't open connection to database\n"; } if (param('m') eq 'entitylist') { entitylist(); } elsif(param('m') eq 'getmarkers') { getmarkers(param('entity')); } sub entitylist { my $sth = $dbh->prepare('select distinct(type) from ch10'); $sth->execute(); print ""; while (my $row = $sth->fetchrow_hashref()) { printf('',ucfirst($row->{type})); } print ""; } sub getmarkers { my ($entity) = @_; print("\n"); my $sth = $dbh->prepare(sprintf('select * from ch10 where type = %s', $dbh->quote($entity))); $sth->execute(); while (my $row = $sth->fetchrow_hashref()) { printf('%s
%s
%s%s
', $row->{lat}, $row->{lng}, $row->{title}, $row->{title}, $row->{adda}, $row->{addb}, $row->{tel}, ); } $sth->finish(); print("
\n"); }