I've figured out a way to insert the results of an SQL search into an HTML page more or less on the fly. However at the point the SQL search results are inserted I need to be able to indent the data. So far I haven't come up with a way to do that. Here's the code I'm using. I have comments where the indent needs to start and end.

#!/usr/bin/perl -w use strict; use DBI; use CGI qw(:standard); my ($dbh, $sth, $count); $dbh = DBI->connect('dbi:mysql:members','root','password') or die "Connection Error: $DBI::errstr\n"; $sth = $dbh->prepare("SELECT LastName, FirstName, City, State, Countr +y, Email FROM people"); $sth->execute (); print header(), start_html; print <<"(END Page Header HTML)"; <html> <head> <title>Page Header</title> </head> <center> <body topmargin="0" leftmargin="0" rightmargin="0"> <div align="center"> <center> <table border="0" cellpadding="0" cellspacing="0" style="border-coll +apse: collapse" bordercolor="#111111" width="100%" id="AutoNumber1"> <tr> <td>Some Text</td></tr> </table> </body> </html> </center> (END Page Header HTML) #### Now I want to indent 5 spaces or app 20 pix print "<br><br><p align=\"left\"><font size=\"5\"><b><u>Your Search Re +sults</u></b></font>"; $count = 0; while (my @val = $sth->fetchrow_array ()) { print p (sprintf ("<p align=\"left\"><font size=\"4\">Last Name = +%s<br><font size=\"4\">First Name = %s<br><p align=\"left\"><font siz +e=\"4\">City = %s<br><font size=\"4\">State = %s<br><font size=\"4\">Country = %s<br> +<font size=\"4\">Email = %s</font>\n", $val[0], $val[1], $val[2], $val[3], $val[4], $val[5])); ++$count; } print p ("<p align=\"left\">$count Total Members"),end_html (); ##### Now I want to stop the indent! print <<"(END FOOTER HTML)"; <html> <head> <title>FOOTER</title> </head> <center> <body topmargin="0" leftmargin="0" rightmargin="0"> <div align="center"> <center> <table width="100%> <tr> <td width="100%"> <p align="left"> <form><input type="button" value="BACK TO SEARCH" onClick="histo +ry.back();"></p></p></form></td> </tr> <tr> <td width="100%"> <img src="http://www.domain/images/blk.gif" height="1" width="10 +0%"></td> </tr> <tr> <td width="100%"> &nbsp;</td> </tr> </table> <table width="100% cellpadding="0"><tr><td width="100%"><p align="cent +er"><font size="1" face="Arial"> <br> © My Company<br> All Rights Reserved<br></font></td> </tr></table> (END FOOTER HTML) $sth->finish (); $dbh->disconnect (); exit (0);

Can anyone tell me what I need to do go indent the search results? Suggestions will be greatly appreciated.

Thanks!

Milt Spain


In reply to Indention of SQL Search Result In An HTML Page by Milti

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.