Madhu Kumar am Montag, 6. März 2006 09.57:
> Hi , 

Hi Madhu Kumar

your problem is not perl, but html related, see below:

> I want to display database records as web page my database 
> contains some entries and which i wanna write as a report in web
> page.
>
> I have written a code for it which fetches the data from database
> which i wil show u below: my requirement is to align each fields and
> dispaly them as a report .
>
> #!/usr/bin/perl -w
> use DBI;
>
> #use CGI qw(:standard);
> #use CGI::Carp qw(fatalsToBrowser carpout);
> print("Content-type: text/html\n\n");
>
>
> my $dbh = open_dbi();
>
> my $sth2 = $dbh->prepare( q{ SELECT * From longdescs } )
>
>                 or die "Can't execute statement  $DBI::errstr";
>
>                 $sth2->execute();
>                 print "\nContent of Database is \n\n";
>
>                 print " bug_id\t who\t  bug_when\t work_time\t
> thetext\t isprivate\t already_wrapped\n";
>
>
>                my( $bug_id, $who, $bug_when, $work_time, $thetext,
> $isprivate, $already_wrapped );
>                $sth2->bind_columns( undef, \$bug_id, \$who,
> \$bug_when, \$work_time, \$thetext, \$isprivate, \$already_wrapped
> );
> while( $sth2->fetch() )
>         {
>         print "$bug_id\t, $who\t, $bug_when\t, $work_time\t $thetext\t
> $isprivate\t $already_wrapped\t \n";
>         }
>         $sth2->finish();
>  print"\n";
> $dbh->disconnect;
> sub open_dbi
[...]
> 
> when i run this script on apache web server it messes up all data and
> displays like this which doesn't give a clear picture of what is
> what.

One or more consecutive \t, \n, ' ' are taken as one white space when 
*rendering* the web page (with exeption, see below). 
You can see your formatted output (only) in the html *source*.

What you can do:
a) put <pre> and </pre> around your output, so your formatting 
    is rendered literally (the easyiest way)
b) use html tables to format your data in columns

There must be at least one modul on search.cpan.org that can display data 
tables as html tables in an easy way.

For all html stuff, http://en.selfhtml.org/ is a good start, it explains all 
in an easy way.

> Content of Database is bug_id who bug_when work_time thetext isprivate
> already_wrapped 6 , 4 , 2006-02-23 10:35:09 , 0.00 Test
> !!!!!!!!!!!!!!!!! 0 0 7 , 6 , 2006-02-23 10:52:50 , 0.00 Test for 0 0
[...]
> i want the code to display records like a clear report with individual
> fileds having spaces in between them, i hav been fighting with the
> code for longtime .

hth,
Hans

--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
<http://learn.perl.org/> <http://learn.perl.org/first-response>


Reply via email to