Gossamer Forum
Home : Products : DBMan : Discussions :

Combining Fields

Quote Reply
Combining Fields
Hi,
Me again! Thanks for all your help so far! I was just wondering if its possible to combine fields. When our users add a record they get 3 options with drop down menus, and when it comes it via email it looks like this: -
|01|02|03| (split with pipes)
Is there away to get it to come in like: -
|010203| (no pipes)
Regards
Many Thanks
Ben

Quote Reply
Re: Combining Fields In reply to
How are you inserting the values into the email?

- Mark

Astro-Boy!!
http://www.zip.com.au/~astroboy/
Quote Reply
Re: Combining Fields In reply to
In the html.pl, under the html_add_success routine I added a section that e-mails the results to me!

my (%rec) = &get_record($in{$db_key}); open (MAIL, "$mailprog") || &cgierr("Can't start mail program"); print MAIL "To: $admin_email\n"; print MAIL "From: $rec{'EMAIL'}\n"; print MAIL "Subject: $html_title\n\n"; foreach $col (@db_cols) { print MAIL "$col$rec{$col}|"; } close (MAIL);

Any help greatly appreciated!
Ben

Quote Reply
Re: Combining Fields In reply to
The pipe in red looks like the problem, try taking it out:

my (%rec) = &get_record($in{$db_key}); open (MAIL, "$mailprog") || &cgierr("Can't start mail program"); print MAIL "To: $admin_email\n"; print MAIL "From: $rec{'EMAIL'}\n"; print MAIL "Subject: $html_title\n\n"; foreach $col (@db_cols) { print MAIL "$col$rec{$col}|"; } close (MAIL);


Hope this helps,

- Mark

Astro-Boy!!
http://www.zip.com.au/~astroboy/
Quote Reply
Re: Combining Fields In reply to
OK thanks I'll give it a try! Will this remove all pipes from the database? I do need some of it split up! For example
|A|B|C|1234|1|
as opposed to
|A|B|C|1|2|3|4|1|
which is what I'm getting now! I need just the 1234 to be 'merged' so to speak and all the rest to be split with pipes!
Thanks for your help
Ben

Quote Reply
Re: Combining Fields In reply to
It will probobly remove the pipe from all records. In order to remove the pipe from just a few fields, you'll need a more complex "write to email" code.

- Mark


Astro-Boy!!
http://www.zip.com.au/~astroboy/
Quote Reply
Re: Combining Fields In reply to
Ah, ok thanks, thinking about it its probably in the last line of that code.
foreach $col (@db_cols) { print MAIL "$col$rec{$col}|"; } close (MAIL);
There must be a way to modify it so it sends some coloums split with a | and others not split. Or maybe there is a sub routine. Do you know where I might find something to this nature or somewhere which might help me write my own.
Thanks again
Ben

Quote Reply
Re: Combining Fields In reply to
OK,
I accually went out and got 2 books for this, 1 on perl, & 1 on cgis. I was looking at different form-mail scrips, and I was wondering is this world work...
Instead of

foreach $col (@db_cols) { print MAIL "$col$rec{$col}|"; } close (MAIL);

Use

print MAIL "$field1{'field1'}|"; "$field2{'field2'}|"; "$field3{'field3'}"; "$field4{'field4'}"; } close (MAIL);

This would give output like.....field1|field2|field3field4

I think, with | (pipe) between 1,2, and 3, but not between 3 & 4, is this correct? Or am I going off on a tangent here?
Anyway thanks for your help,
Ben