Adding every number of a specific together by user.
Posted: Thu Oct 08, 2009 6:12 am
Hello everyone,
I'm sorry about the title. I would also like to apologize in advance for my newbieness and the rest of this badly-written post. This has been driving me crazy for about twenty hours straight and my mind is too scattered and sleep-deprived to make this post readable. I'll try, though. Here's the situation:
I have a referral system on my website. There's also a few different numerical values I assign to each member in a table called sup_numbers.
I want to find the total value of each of the specific numbers assigned to each user on the table (let's call this value sys1_num) that was referred by the person viewing the page.
Sorry, that didn't make any sense, did it?
Here's an example:
Jim refers Jen, Sally, Susie, and Kenny. Jen's value A=5, Sally's A=9, Susie's A=8, and Kenny's A=23.
Value B is supposed to be the total value of the referral's A values, so in Jim's case it would be Jen's A+Sally's A+Susie's A+Kenny's A, or 45 (I hope I added that correctly...)
What I need is a way to display the value B of the member viewing that page. This is what I have so far, and it worked out horrible.
I know, I know, it's horrible. I'm a total newbie at this, but I managed to get everything else working (thank Soup), except for this one thing. So does anyone know how I can add that string together? I need help; I don't even know if I used the word 'string' correctly!
Thanks in advance,
Stuffs
P.S. If this makes no ense at all, wait until tomorrow. I'll clean it all up after a good night's sleep. I'm just hoping someone could understand it all and help me out while I'm asleep! D:
I'm sorry about the title. I would also like to apologize in advance for my newbieness and the rest of this badly-written post. This has been driving me crazy for about twenty hours straight and my mind is too scattered and sleep-deprived to make this post readable. I'll try, though. Here's the situation:
I have a referral system on my website. There's also a few different numerical values I assign to each member in a table called sup_numbers.
I want to find the total value of each of the specific numbers assigned to each user on the table (let's call this value sys1_num) that was referred by the person viewing the page.
Sorry, that didn't make any sense, did it?
Here's an example:
Jim refers Jen, Sally, Susie, and Kenny. Jen's value A=5, Sally's A=9, Susie's A=8, and Kenny's A=23.
Value B is supposed to be the total value of the referral's A values, so in Jim's case it would be Jen's A+Sally's A+Susie's A+Kenny's A, or 45 (I hope I added that correctly...)
What I need is a way to display the value B of the member viewing that page. This is what I have so far, and it worked out horrible.
Code: Select all
function value_b() {
global $user;
$r__valb = db_query("SELECT w.value_a
FROM {referral} r INNER JOIN {users} u USING(uid) INNER JOIN
{sup_numbers} w USING(uid)
WHERE referral_uid = %d", $user->uid);
while ($om_valb = db_fetch_object($r__valb)) {
$output .= t("Value B") .": ". $om_valb;
}
}
Thanks in advance,
Stuffs
P.S. If this makes no ense at all, wait until tomorrow. I'll clean it all up after a good night's sleep. I'm just hoping someone could understand it all and help me out while I'm asleep! D: