10.07.2015 Views

Beginning Web Development With Perl : From Novice to ... - Nabo

Beginning Web Development With Perl : From Novice to ... - Nabo

Beginning Web Development With Perl : From Novice to ... - Nabo

SHOW MORE
SHOW LESS

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

CHAPTER 3 ■ DATABASES AND PERL 69Figure 3-2. Data from a SQL query has been placed in<strong>to</strong> an HTML table.Next, the results are iterated through and the table dynamically created on the fly:while (my ($hostname,$username) = $sth->fetchrow_array()) {if ($hostname eq "") {$hostname = "undef";}print Tr({-align=>'CENTER',-valign=>'TOP'},[td(["$username","$hostname"])]);}Each row of the table must be created within the while() loop in order for it <strong>to</strong> make sensein an HTML table format.You could also place values retrieved in<strong>to</strong> a hash within the while() loop, or you coulduse other methods, including fetchrow_hashref() and others. See the DBI documentation(type perldoc DBI from a terminal window) for more information about other methods.

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!