develooper Front page | perl.beginners | Postings from April 2002

perl / database question

Thread Next
From:
Johnson, Shaunn
Date:
April 2, 2002 09:48
Subject:
perl / database question
Message ID:
73309C2FDD95D11192E60008C7B1D5BB0452E187@snt452.corp.bcbsm.com
Howdy:

Running Postgres 7.1.3 on RedHat Linux 2.4.7
and Perl 5.6.1.

My goal is this:

I am trying to put a perl / cgi script
together to display a list of tables
I pull back from Postgres.  I would 
like to put the table in a scrolling
menu form page.

So far I have this:

[snip code]

#!/usr/bin/perl -w

$debug=2;

use Pg;
use CGI qw(:standard);
use CGI::Carp 'fatalsToBrowser';
require "/var/www/hminclude.pl";

# Config stuff
#
#

my $TITLE = 'Table Listing';

print header,
        start_html(-title=>"Get Table List", -bgcolor=>'white');
if (!param() ) {
        start_form();
} else {
        print "$!";
}

print end_html;

###


sub start_form {
# connect to database
#
$conn=bcnOpen();
$list_tbl=doquery('Table List', "select relname from pg_class where relname
not like 'pg\\_%' and relkind = 'r' order by 1");
}

while ( my($first, @full_list)=$list_tbl->fetchrow){
print h1($TITLE),
        hr;
print start_form,
print "<select name="tables" multiple size=3>";
print "<option>"$first;
print "</select>";

print submit,
        reset;
}

[/snip code]


Few notes:

Yes I am very new at this ... I was hoping I
could learn from some examples floating
around ... but I'm not sure where my results
should merge with the code (successfully).

The 'while' statement: I want to say 'while
reading from this list of tables, create
a scrolling window and populate it with
the results from the sql query from above'.

Are there any examples as to how to 
do this?

Thanks!

-X

Thread Next


nntp.perl.org: Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at ask@perl.org | Group listing | About