#!/usr/local/bin/perl -w # Query coordinates, texture, VRML and interior use DBI; use CGI; $database = '***'; $hostname = '***'; $user = '***'; $password = '***'; $query = new CGI; print $query->header; $TITLE="Query Example"; $path_info = $query->path_info; # If no path information is provided, then we create # a side-by-side frame set if (!$path_info) { &print_frameset; exit 0; } #Start HTML page &print_html_header; &print_query if $path_info=~/query/; &print_response if $path_info=~/response/; &print_end; exit; #---------------------------------------- # Subroutines #----------------------------------------- sub print_html_header { print $query->start_html($TITLE); } sub print_end { print $query->end_html; } sub print_frameset { $script_name = $query->script_name; print <$TITLE EOF ; exit 0; } sub print_query { $script_name = $query->script_name; print "

Query

\n"; print $query->startform(-action=>"$script_name/response",-TARGET=>"response"); print "

What would like to see? ", $query->popup_menu(-name=>'keyword', -values=>['coordinates','texture','VRML world', 'interior']), "

"; print $query->submit; print $query->endform; print qq{

back}; } sub print_response { print "

Result

\n"; unless ($query->param) { print "No query submitted yet."; return; } print "

Your preferences are: ",$query->param('keyword'),"
"; if (($query->param('keyword')) eq 'coordinates') { #Query database--1------------------------------------------------ $dbh = DBI->connect ("DBI:mysql:$database:$hostname", $user,$password); $sth = $dbh->prepare("select fid,nid,xc,yc,zc from comobg,surfg,face,node where cidg=1 and type='s' and oid=sidg and fids=fid and nidf=nid"); $sth->execute; $num=0; print "
"; while ( @field = $sth->fetchrow) { $all[$num]=[@field]; #print "$num: $field[3] $field[4]
"; $num++; } print "
"; $sth->finish; #---printing coordinates------------------------ $k=0; while ($k<$num) { $j=0; while ($j<5) { print "$all[$k]->[$j++] "; } $k++; print "
"; } #--------END------------------------------------- $dbh->disconnect; #Query database END--1------------------------------------------- } elsif (($query->param('keyword')) eq 'texture'){ #Query database-2------------------------------------------------- $dbh = DBI->connect ("DBI:mysql:$database:$hostname", $user,$password); $sth = $dbh->prepare("select tname from surfa,texta where surfa.sida=18 and tids=tid"); $sth->execute; $i=0; print "
"; while ($file_name = $sth->fetchrow) { print qq {


See the image}; $i++; } print "
"; $sth->finish; print "$all[1]
"; # $dbh->disconnect; #Query database END-2-------------------------------------------- } elsif (($query->param('keyword')) eq 'VRML world') { print qq {


Get the file}; } else { print qq{}; } ; }