Gossamer Forum
Home : Products : DBMan : Installation :

Calculations in DBMan

Quote Reply
Calculations in DBMan
Ok By now you all probably know my database
( Annoing Questions)
but here is the thing i want to add in
html_add_success a link to another page that will calculate how many states were added list price for first (example $40)
Than second or more ($30) Each
At the end will display Total Purchase.
Now How can i do this?
Quote Reply
Re: Calculations in DBMan In reply to
Do you want the total saved in your database? Whether you do or not will make a difference in how you go about it.

Assuming you don't want the total saved (which is much easier Smile ), here's what you do.

Before the line

&html_print_headers;

add

Code:
%rec = &get_record($in{$db_key});
@states = split (/\Q$db_delim\E/o,$rec{'States'});
unless (!(@states)) {
shift @states;
$total = 40 + (scalar(@states)*30);
}

(Change States above to the actual name of your field.)

change

&html_record(&get_record($in{$db_key}));

to

&html_record(%rec);

Then within the print qq| statement add something like

Your total charge is \$$total.




------------------
JPD





Quote Reply
Re: Calculations in DBMan In reply to
As usual your are wright
works perfectly.
But how can this total be emailed to me and to the customer.
I already have email set up
so when customer adds new record thank YOU email is send to him and to me but i cant figure out how 2 add this total to it

Thanks again.
Quote Reply
Re: Calculations in DBMan In reply to
Where is your email routine set up? Is it in db.cgi or in html.pl? If it's in db.cgi, you'll have to do the calculations in the same subroutine (I'm guessing it would be within sub add_record.)




------------------
JPD





Quote Reply
Re: Calculations in DBMan In reply to
No it's done in db.cgi
Quote Reply
Re: Calculations in DBMan In reply to
I tried to add in the same subrutine but then it does not send the emial at all?
Quote Reply
Re: Calculations in DBMan In reply to
OK I got it.
Works Great almost done with the database
Thanks to you JPD
Quote Reply
Re: Calculations in DBMan In reply to
I guess my little nap this afternoon helped you as well as me. You found your answers on your own! Smile

Congrats! I hope you'll let us see your database when it's ready.


------------------
JPD