View Full Version : Trouble with print formatting
charbort
09-22-2003, 09:36 PM
My current code looks like this:
foreach $field (@Field_Order) {
if ($Config{'print_blank_fields'} || $Form{$field} ne '') {
print MAIL "$field: $Form{$field}','";
}
}
}
Which prints the field name and value separated with a colon, but what I'm trying to figure out is how can I print all the field names in one line with the values below. For example:
field name1, field name2, field name3, etc....
value1, value2, value3, etc...
I'm trying to have the above layout so the information can be imported into excel instead of having to cut-n-pase each value separately.
Thanks in advance,
C
ACJavascript
09-22-2003, 09:58 PM
You could do somthing like this
print MAIL "<table border=0><tr>";
foreach $field (@Field_Order) {
if ($Config{'print_blank_fields'} || $Form{$field} ne '') {
print MAIL "<td>$field</td>''";
}
}
print MAIL "</tr><tr>";
foreach $field (@Field_Order) {
if ($Config{'print_blank_fields'} || $Form{$field} ne '') {
print MAIL "<td>$FORM{'field'}</td>''";
}
}
print MAIL "</tr></table>";
charbort
09-24-2003, 05:33 PM
ACJavascript, It looks good and I tried it but I screwed something up since I get a 500 error now. I probably should have given you the whole send_mail portion initially. Here it is with the new code inserted and thanks in advance for your assistance.
C
------code below -------------
sub send_mail {
# Localize variables used in this subroutine. #
local($print_config,$key,$sort_order,$sorted_field,$env_report);
# Open The Mail Program
open(MAIL,"|$mailprog");
print MAIL "To: $Config{'recipient'}\n";
print MAIL "From: $Config{'email'} ($Config{'realname'})\n";
# Check for Message Subject
if (exists $Config{subject}) { print MAIL "Subject: $Config{subject}\n\n" }
else { print MAIL "Subject: Subscription page\n\n" }
print MAIL "The following information was submitted from an Arizona Game & Fish Department Web site. It was submitted by\n";
print MAIL "$Config{'realname'} ($Config{'email'}) on $date\n";
print MAIL "-" x 75 . "\n\n";
if (@Print_Config) {
foreach $print_config (@Print_Config) {
if ($Config{$print_config}) {
print MAIL "$print_config: $Config{$print_config}\n\n";
}
}
}
# If a sort order is specified, sort the form fields based on that. #
if ($Config{'sort'} =~ /^order:.*,.*/) {
# Remove extraneous line breaks and spaces, remove the order: #
# directive and split the sort fields into an array. #
local $sort_order = $Config{'sort'};
$sort_order =~ s/(\s+|\n)?,(\s+|\n)?/,/g;
$sort_order =~ s/(\s+)?\n+(\s+)?//g;
$sort_order =~ s/order://;
@sorted_fields = split(/,/, $sort_order);
# For each sorted field, if it has a value or the print blank #
# fields option is turned on print the form field and value. #
print MAIL "<table border=0><tr>";
foreach $sorted_field (@sorted_fields) {
if ($Config{'print_blank_fields'} || $Form{$sorted_field} ne '') {
print MAIL "<td>$field</td>";
}
}
print MAIL "</tr><tr>";
foreach $field @sorted_fields){
if ($Config{'print_blank_fields'} || $Form{$sorted_fields} ne '') {
print MAIL "<td>$Form{$field}</td>";
}
foreach $sorted_field (@sorted_fields) {
if ($Config{'print_blank_fields'} || $Form{$sorted_field} ne '') {
print MAIL "$sorted_field: $Form{$sorted_field}','";
}
}
}
# Otherwise, print fields in order they were sent or alphabetically. #
else {
# Sort alphabetically if specified: #
if ($Config{'sort'} eq 'alphabetic') {
@Field_Order = sort @Field_Order;
}
# For each form field, if it has a value or the print blank #
# fields option is turned on print the form field and value. #
print MAIL "<table border=0><tr>";
foreach $field (@Field_Order) {
if ($Config{'print_blank_fields'} || $Form{$field} ne '') {
print MAIL "<td>$field</td>";
}
}
print MAIL "</tr><tr>";
foreach $field (@Field_Order){
if ($Config{'print_blank_fields'} || $Form{$field} ne '') {
print MAIL "<td>$Form{$field}</td>";
}
# Send any specified Environment Variables to recipient. #
foreach $env_report (@Env_Report) {
if ($ENV{$env_report}) {
print MAIL "$env_report: $ENV{$env_report}\n";
}
}
close (MAIL);
}
ACJavascript
09-25-2003, 12:19 AM
I think I found the error.
foreach $sorted_field (@sorted_fields) {
if ($Config{'print_blank_fields'} || $Form{$sorted_field} ne '') {
print MAIL "<td>$field</td>";
}
}
print MAIL "</tr><tr>";
foreach $field @sorted_fields){
if ($Config{'print_blank_fields'} || $Form{$sorted_fields} ne '') {
print MAIL "<td>$Form{$field}</td>";
}
}
There should be a } there. As shown above.
charbort
09-25-2003, 02:03 AM
Thanks, I realized that when I was working with it later, but for some reason the HTML portion of the code isn't working.
I get the email in and it actually has the tags in it? Any ideas?
C
ACJavascript
09-25-2003, 05:07 AM
huh mabye this
foreach $field (@Field_Order) {
if ($Config{'print_blank_fields'} || $Form{$field} ne '') {
print MAIL " $field ''";
}
}
foreach $field (@Field_Order) {
if ($Config{'print_blank_fields'} || $Form{$field} ne '') {
print MAIL " $FORM{'field'} ''";
}
}
vBulletin® v3.8.2, Copyright ©2000-2012, Jelsoft Enterprises Ltd.