Sum function for multiple recordsets?

Sum function for multiple recordsets?

am 25.12.2007 04:24:50 von Jay

--0-1443813251-1198553090=:81042
Content-Type: text/plain; charset=iso-8859-1
Content-Transfer-Encoding: 8bit

I'm getting a health insurance quote engine going...

http://www.insuranceshoppers.net/getquotes/short-term-health .php

.... it sends me an email with the info, and enters the info into a "leads" table in mysql.

Then I want to have it show the rates (on a new page using $_GET) from a table I have setup with the rates of multiple companies. Since the rates are based on age and gender and it could be 1 or 2 people plus the possibility of adding children (the total rate is just the sum of each persons individual rate), I've been working on making a recordset for the primary applicant, the spouse, and children and telling it to add them together. (that seems like the easiest way, but I'm a newbie)

My question: is there a php function or a way I can create the 3 recordsets in Dreamweaver and tell it to just add them up and display the results in a repeat region? And is this even the best way to approach it?

Cheers,

Jay

--0-1443813251-1198553090=:81042--

Re: Sum function for multiple recordsets?

am 03.01.2008 05:16:11 von dmagick

jay@insuranceshoppers.net wrote:
> I'm getting a health insurance quote engine going...
>
> http://www.insuranceshoppers.net/getquotes/short-term-health .php
>
> ... it sends me an email with the info, and enters the info into a "leads" table in mysql.
>
> Then I want to have it show the rates (on a new page using $_GET) from a table I have setup with the rates of multiple companies. Since the rates are based on age and gender and it could be 1 or 2 people plus the possibility of adding children (the total rate is just the sum of each persons individual rate), I've been working on making a recordset for the primary applicant, the spouse, and children and telling it to add them together. (that seems like the easiest way, but I'm a newbie)
>
> My question: is there a php function or a way I can create the 3 recordsets in Dreamweaver and tell it to just add them up and display the results in a repeat region? And is this even the best way to approach it?

You could probably get the database to do this directly but without
knowing what you're storing and what you have in the first place it's
hard to tell.

select sum(rates) as totalrate from table where rateid in (1,2,3);

http://dev.mysql.com/doc/refman/4.1/en/group-by-functions.ht ml#function_sum

--
Postgresql & php tutorials
http://www.designmagick.com/

--
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php