Beefy Boxes and Bandwidth Generously Provided by pair Networks
Syntactic Confectionery Delight
 
PerlMonks  

comment on

( #3333=superdoc: print w/replies, xml ) Need Help??

I'm working on the final bits of a new web store application for my employer, and I've run into a bit of a pickle. We need to send the customer an email receipt for their order, and we'd like to send them a nicely formatted table of the items in their cart.

I can't use HTML, as there's a company policy decision stating that we don't put HTML in emails. (I agree - I read much email via PINE myself, and I hate HTML in my inbox). Therefore, format is the way to go. I think.

My question is, how do I make a format against a loop? I'm pulling the data from my database, and it's all working fine in HTML::Template. So I get:

$sqlString = "SELECT * FROM CartItems WHERE txtSessId = ?"; $sth = $dbh->prepare($sqlString); $sth->execute($session) $cartItemsRef = $sth->fetchall_arrayref({});

for a great return set for a TMPL_LOOP in my HTML templates. I can't format those well for a text-based table - I've tried. Given a format like this:

format RECEIPT = Item Quantity Price -------------------------------------------- @<<<<<<<<<<<<<<<<<<<<< @<<<<< @####.## $vars,$go,$here .

How do I loop this on the $cartItemsRef? I don't understand the format system deeply enough to do this.


In reply to Format question... by khudgins

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



  • Are you posting in the right place? Check out Where do I post X? to know for sure.
  • Posts may use any of the Perl Monks Approved HTML tags. Currently these include the following:
    <code> <a> <b> <big> <blockquote> <br /> <dd> <dl> <dt> <em> <font> <h1> <h2> <h3> <h4> <h5> <h6> <hr /> <i> <li> <nbsp> <ol> <p> <small> <strike> <strong> <sub> <sup> <table> <td> <th> <tr> <tt> <u> <ul>
  • Snippets of code should be wrapped in <code> tags not <pre> tags. In fact, <pre> tags should generally be avoided. If they must be used, extreme care should be taken to ensure that their contents do not have long lines (<70 chars), in order to prevent horizontal scrolling (and possible janitor intervention).
  • Want more info? How to link or or How to display code and escape characters are good places to start.
Log In?
Username:
Password:

What's my password?
Create A New User
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others meditating upon the Monastery: (5)
As of 2021-06-12 21:18 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    What does the "s" stand for in "perls"? (Whence perls)












    Results (53 votes). Check out past polls.

    Notices?