One way is:
print $cgi->start_table({-border=>'1'});
while(my @row = $query->fetchrow_array()) {
print $cgi->Tr({-align=>LEFT, -valign=>MIDDLE},
$cgi->td({-bgcolor=>green,-width=>'150'}, \@row));
}
print $cgi->end_table;
> Mailing-List: contact [EMAIL PROTECTED]; run by ezmlm
> Precedence: bulk
> List-Post: <mailto:[EMAIL PROTECTED]>
> List-Help: <mailto:[EMAIL PROTECTED]>
> List-Unsubscribe: <mailto:[EMAIL PROTECTED]>
> List-Subscribe: <mailto:[EMAIL PROTECTED]>
> Sender: [EMAIL PROTECTED]
> Date: Tue, 03 Jul 2001 10:26:32 -0700
> From: James Kelty <[EMAIL PROTECTED]>
> X-Accept-Language: en
> Content-Type: text/plain; charset=us-ascii
> X-OriginalArrivalTime: 03 Jul 2001 17:41:48.0515 (UTC) FILETIME=[6F71EB30:01C103E7]
> X-Spam-Rating: onion.valueclick.com 1.6.2 0/1000/N
>
> Ok,
>
> I have connected to a MySQL database, and I am creating a table based on
> the row fetched which is not a problem. But! How can I write a table
> when multiple rows are fetched without writing a new table for each row?
> Here is the code I am using at the moment. I had it wrapped with a while
> statement, but that wrote a table for each row.
>
>
> CURRENT CODE:
> @row = $query->fetchrow_array();
> print $cgi->table({-border=>'1'},
> Tr({-align=>LEFT, -valign=>MIDDLE},
> [
>
> td({-bgcolor=>green,-width=>'150'},["$row[0]","$row[1]","$row[2]","$row[3]"])
>
> ]
> )
> );
> print $cgi->end_table;
>
> CODE TO WRITE A TABLE FOR EACH ROW: (Not used at the moment)
>
> while(@row = $query->fetchrow_array()) {
> print $cgi->table({-border=>'1'},
> Tr({-align=>LEFT, -valign=>MIDDLE},
> [
>
> td({-bgcolor=>green,-width=>'150'},["$row[0]","$row[1]","$row[2]","$row[3]"])
>
> ]
> )
> );
> print $cgi->end_table;
> }
> --
> ------
> James Kelty
> Sr. Unix Systems Administrator
> The Ashland Agency
> [EMAIL PROTECTED]
>
--
Vinicius Jose Latorre
CPqD - Telecom & IT Solutions
e-mail : [EMAIL PROTECTED]