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

perl / database question

Thread Next
Johnson, Shaunn
April 2, 2002 09:48
perl / database question
Message ID:

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


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

# Config stuff

my $TITLE = 'Table Listing';

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

print end_html;


sub start_form {
# connect to database
$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),
print start_form,
print "<select name="tables" multiple size=3>";
print "<option>"$first;
print "</select>";

print submit,

[/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?



Thread Next Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at | Group listing | About