r_mehmed has asked for the wisdom of the Perl Monks concerning the following question:
Thanks#!perl -wT use CGI; use CGI::Carp qw ( fatalsToBrowser ); use DBI; use strict; my $q = new CGI; my %attr = (RaiseError=>1, PrintError=>1); my @field_name = qw ( property_id address_1 address_2 county city z +ip description status bedroom bathroom ); my @field_desc = qw ( ID Address Address County City PostalCode Des +cription Status Bedrooms Bathrooms ); my $dbh = DBI->connect("dbi:mysqlPP:$db:$server", $username, $passw +ord,{RaiseError =>1}); print $q->header("text/html"), $q->start_html(-title=>"Lettingsetc.co.uk | Admin | Edit", -sr +c=>"/mycss.css"), $q->h1("Lettingsetc.co.uk"), $q->h4("Administration>Edit property details!"); my $field_list = join (",", @field_name); print <<HTML; <H1>All Properties</H1> <TABLE BORDER=1> <TR> HTML my $SQL = "SELECT $field_list FROM property"; my $i; foreach $i(@field_desc) { print "<TH>$i</TH>\n"; } print qq `</TR><TR>`; my $sth = $dbh->prepare($SQL); $sth->execute() or die $dbh->errstr; my $row; foreach $row( $sth->fetchrow_array)# while more rows fetch next one { print "<TD>$row</TD>\n";# print row data in HTML } print "</TR></TABLE>"; print $q->end_html; $dbh->disconnect() or die $dbh->errstr;
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: foreach loop
by pfaut (Priest) on Jan 20, 2003 at 18:26 UTC | |
|
Re: foreach loop
by poj (Abbot) on Jan 20, 2003 at 18:45 UTC | |
|
Re: foreach loop
by hardburn (Abbot) on Jan 20, 2003 at 18:25 UTC |