Make sure to print a "header" before printing your content. I didn't see
one posted and didn't see any other threads about this.
But before you begin printing your output (aka the HTML) you need to
have something along the lines of:
print "Content/type: text/html\n";
On a personal preference note I would much prefer something along the
lines of....
foreach my $aref (@History) {
print $aref->[0];
etc.
}
If we are going to advocate the use of array/hash refs, etc. we should
use them all the way, but I suppose that is personal preference. Of
course I would also advocate the use of hash refs instead of array refs
in case the fields of the database change order, more are inserted in
between, and it makes the code more self documenting.
http://danconia.org
Robin Cragg wrote:
> Hi Mark,
>
> given how small your data chunk is, you can do it any way you'd like.
> Here's a chunk that works ..
>
> (Query_Database() just returns an array where each element contains an
> array ref to all the elements of that column.)
>
> @History = Query_Database("SELECT
> Change_Date,Person,Event,History.Ticket_Number,Tickets.Open_Code from
> History LEFT JOIN Tickets ON Tickets.Ticket_Number =
> History.Ticket_Number WHERE $_ ORDER BY $Order;");
>
> print "<CENTER><TABLE BORDER=1>\n";
>
> for $a (0 .. (scalar @History -1)) {
> print "<TR><TD>$History[$a][0]</TD>\n";
> print "<TD>$History[$a][1]</TD>\n";
> print "<TD>$History[$a][2]</TD>\n";
> print "<TD>$History[$a][3]</TD>\n";
> print "<TD>$History[$a][4]</TD></TR>\n";
> }
> print "</TABLE>\n";
>
> I did it this way so I could add different formatting to each row if I
> wanted to, but ended up not bothering...
>
> R
>
>
> At 18:32 10/09/2002 +0100, Mark Wildey wrote:
>
>> I'm very new to Perl and so far have built a script to read a large text
>> file, create a MS Access db and subsequently run several SQL statements
>> against my new db.
>>
>> I would like to present the information in html/web format and am
>> struggling
>> on the best way to build the html code and invoke the page.
>>
>> Looking at CGI it appears to present a web page, which then calls some
>> code
>> once the user has interacted, is the wrong way round for me. Had a
>> look at
>> Tk but I'm not completely sure that this is the best way.
>>
>> My latest attempt was with HTML-Templates but I cannot get these to work
>> !!!!
>>
>> Templates seemed the best way forward as I know the format of the page
>> and
>> just need to pass a few ( 20 ish ) variables for display
>>
>> So my questions is, given that I want to invoke a script and generate
>> data
>> which I present in html format, what is the best way ( CGI, Tk, HTML
>> templates, or some other )
>>
>> If you have any recommendation just point me in the direction and I'll
>> work
>> it out. Or if you have a simple piece of code that would be top dollar.
>>
>> Regards and thanks in advance
>>
>> Mark ( currently on a very steep learning curve )
>
>
>
--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]