bogglemaster89 has asked for the wisdom of the Perl Monks concerning the following question:

hello Monks! I have had this problem for days! I got sql and perl to talk and print an html table, which displays lovely in its own little site, however I cant seem to get it to display on a webpage with css and other bits of html....how can i do this? I managed to 'print' the html out and get it to display, but .css file failed, the code is as below:
#!\strawberry\perl\bin\perl.exe use DBI; print "Content-type: text/html\n\n"; print "<html>\n" ; print "<head>" ; print "<title>$ENV{'SERVER_NAME'}: perl on the browser test</title>\n" + ; print "</head>" ; print "\n" ; print "<body bgcolor=\"#FFFFFF\" text=\"#000000\" link=\"#000000\" vli +nk=\"#000000\" alink=\"#000000\">\n" ; print "\n" ; print "<p>This shows that perl is displaying on the website!</p>" ; print "<p>test</p>"; $proof = '<p>proof of the pudding</p>'; print "$proof"; $dbh = DBI->connect('dbi:mysql:aKDatabase','root','password') or die "Connection Error: $DBI::errstr\n"; $sql = "select cost, membertype from membershiptbl"; $sth = $dbh->prepare($sql); $sth->execute or die "SQL Error: $DBI::errstr\n"; print "<p>beginning database search \n</p>"; while (@row = $sth->fetchrow_array) { print "<p>@row</p>"; } print "above is your results \n"; THE ABOVE WORKS and displays a lovely table, which only took me a few +days to get working :-D <head><link rel="stylesheet" type="text/css" href="aberKarateHomeCSS.css" /> </head> <div id="logopositioning"><a href="aberKarateHome.html"><IMG BORDER="0 +" img src="karatelogo.jpg" alt="The Aberystwyth University Shotokan K +arate Club Logo"</a> </div> <div id= "header"> <div id="headertext" <h1> Aberystwyth Karate Club < +/h1></div> </div> <div id="sidebarlink"> <a href="aberKarateHome.html">Home</a> <a href= +"aberKarateLogin.html">/login</a></div> <div id="sidebar"> <div id="sidebartitle"><h3>Navigation</h3> </div> <div id="sidebarborder"> <li> <a href="aberKarateHome.html">Homepage</a> </li> <li> <a href="aberKarateAboutUs.html">About us</a> </li> <li> <a href="aberKarateFindUs.html">Find us</a> </li> <li> <a href="aberKarateCosts.html">Costs</a> </li> <li> <a href="aberKarateEvents.html">Events</a> </li> <li> <a href="aberKarateProfiles.html">Profiles</a> </li> <li> <a href="aberKarateSocials.html">Socials</a> </li> <li> <a href="aberKarateForum.html">Forum</a> </li> <li> <a href="aberKarateContactUs.html">Contact us!</a> </li> </div> </div> <div id= "maintext"> <h1> Costs</h1> THE PLAN IS THAT A TABLE OF COSTS (WITH THE DATA COMING FROM THE SQL B +ACKEND GOES HERE! <h2> Further Notes </h2> <p> Unfortently at the moment students from the Penweddig Class are un +able to train at the University sessions. This is due to the age limi +ts involved with the university and is currently out of our hands. </ +p> <p> We often have special offers avaliable to new comers at the beginn +ing and end of the year! Feel free to <a href="aberKarateContactUs.ht +ml">contact us</a> for more information! </p> </div>
----------------------------------------------------------- END OF CODE ----------------------------------------------------------- so yeah thats my question, how can i display this output, that is the results of the script on the website, rather then having it in its own useless little world? I hope this is clear, I want to merge the two! bogglemaster89.

Replies are listed 'Best First'.
Re: perl to display on a website
by hangon (Deacon) on Mar 04, 2010 at 01:19 UTC

    Since you're sending the page from (presumably) cgi-bin, it is not relative to your document root. You need to specify an absolute path for the stylesheet. Same for any images you use on the page.

Re: perl to display on a website
by Skriptke (Acolyte) on Mar 04, 2010 at 08:42 UTC
    As I have already commented, in HTML, use relative path to Web root.

    We also recommend that you use a template system:
    Nes (the best, not that I am the author) :-)
    HTML::Mason
    Template::Toolkit
    HTML::Template
    ...

    Update:
    ".exe" is WIN32?
    Nes does not work on WIN32, sorry.
      We? Are you more than one person or royalty? :)
        Not my fault, the fault is translate.google. :)
        Sorry for my english.

        Update:
        Answer 2:
        Yes, I am, and Google Translate. :-)