Johnson, Shaunn [[EMAIL PROTECTED]] quoth:
*>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?

There are precious few out there as I went looking for a bare bones
example of something very similar for the CPAN Mirror page since I am not
a Web/CGI person and came up completely empty save for the examples from
the Perl DBI book http://examples.oreilly.com/perldbi/

I use MySQL but I think the Postgres fretchrow is very similar to the
MySQL fetchrow so you'll have something like:

my $sth = $dbh->prepare( "
            SELECT name,summary
            FROM list
            ORDER by name
          " );
$sth->execute;

while ( my ( $name, $summary ) = $sth->fetchrow_array ) {
    print <<EOF;
<TR><TD>$name</TD>
</TR>
EOF
  }

similarly for a select list/pull-down menu list

    my $sth = $dbh->prepare( "
                SELECT DISTINCT category
                FROM list
                ORDER by category
              " );
    $sth->execute();
    my %categories;

    while ( my ( $category ) = $sth->fetchrow_array ) {
@categories{split(' ', $category)} = ();
}
    for my $category (sort keys %categories) {

print<<EOF;
<OPTION  VALUE="$category">$category</OPTION>
EOF
}
print<<EOF;
</SELECT></P>
<P><INPUT TYPE="submit" VALUE="Category"></P>
</FORM>

where you make the query then dump out the contents in a while loop with a
HERE doc. Your mileage may vary, but that's basically it :)

e.

-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to