Beefy Boxes and Bandwidth Generously Provided by pair Networks
more useful options
 
PerlMonks  

Indention of SQL Search Result In An HTML Page

by Milti (Acolyte)
on Sep 23, 2013 at 23:25 UTC ( #1055403=perlquestion: print w/ replies, xml ) Need Help??
Milti has asked for the wisdom of the Perl Monks concerning the following question:

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

Comment on Indention of SQL Search Result In An HTML Page
Download Code
Re: Indention of SQL Search Result In An HTML Page
by keszler (Priest) on Sep 24, 2013 at 03:37 UTC
Re: Indention of SQL Search Result In An HTML Page
by NetWallah (Abbot) on Sep 24, 2013 at 03:40 UTC
    The preferred positioning mechanism, as keszler (++) indicates, is CSS.

    That has a fairly steep learning curve, for someone not intimate with HTML and styling concepts.

    For your simple use case, I'd suggest embedded tables.

    Use an outer table without borders, and embed an empty cell, followed by your first (offset) table.

    FYI- the empty cell can be filled with 5 x "&nbsp;" which represents a non-breaking space.

                 My goal ... to kill off the slow brain cells that are holding me back from synergizing my knowledge of vertically integrated mobile platforms in local cloud-based content management system datafication.

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: perlquestion [id://1055403]
Approved by marinersk
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others musing on the Monastery: (7)
As of 2014-09-23 10:20 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    How do you remember the number of days in each month?











    Results (217 votes), past polls