| We hope you enjoy your visit. You're currently viewing our forum as a guest. This means you are limited to certain areas of the board and there are some features you can't use. If you join our community, you'll be able to access member-only sections, and use many member-only features such as customizing your profile, sending personal messages, and voting in polls. Registration is simple, fast, and completely free. Join our community! If you're already a member please log in to your account to access all of our features: |
| php/mysql; adding values | |
|---|---|
| Tweet Topic Started: Apr 1 2005, 08:03 AM (292 Views) | |
| mathiaus | Apr 1 2005, 08:03 AM Post #1 |
|
mathiaus maximus™
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]()
|
Right, it's me again! I thought I'd post this here so I wouldn't have to wait till after IF dropouts This one I just can't get my head around at all :ph34r: anyways here my problem.... I have a mysql with a table called members. The things in this row are
Now what I am trying to do is to take all the values of 'points' and add them together for each 'memgroup'. So far the best thing I have found is to add all of the rows for each group up rather than the actual values. This was using the count(*) thingy. There is a set number of memgroups which is 6 but a changing number of members within each group and overall Any ideas or help or links or basicly anything which results in me achieving me this would be very mutch appreciated Many thanks in advanced Matt
|
![]() |
|
| Rory | Apr 1 2005, 08:19 AM Post #2 |
|
i;m a mess
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]()
|
OK, if you have 6 membergroups, are they numbered 1-6? or are called something? if they are not numbered, then what you should do is create a new table called membergroups and give it a primary key called membergroup_id and then the name, permissions etc. (depending on what your membergroup will do) then, in your members table replace membergroup with membergroup_id as a foreign key. ok, so if you have the member groups numbered 1-6, then you should do a for statement that loops through each membergroup number:
you should then be able to access what the total for each membergroup by going: echo $countArray[2]; ^ that should show the 2nd membergroup count. I'm not 100% sure if all the code is correct, but it should be (at least the principles behind it should work... i hope) |
![]() |
|
| mathiaus | Apr 1 2005, 09:23 AM Post #3 |
|
mathiaus maximus™
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]()
|
Ok. Some parts of the code make a bit of sense to me (still a complete n00b!) However I get the following error when I use it
which is the line for ($i = 1; $i<=6; $i++) { any ideas as to whats causing the problem? Thanks Matt |
![]() |
|
| Rory | Apr 1 2005, 09:30 AM Post #4 |
|
i;m a mess
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]()
|
i forgot two ;'s, so that might be the problem. i edited my post with the updated version, so check that and see if it works. |
![]() |
|
| mathiaus | Apr 1 2005, 09:45 AM Post #5 |
|
mathiaus maximus™
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]()
|
Works wonderfully thanks saves the day again!! And quickly as well! |
![]() |
|
| Rory | Apr 1 2005, 09:48 AM Post #6 |
|
i;m a mess
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]()
|
No problem. It's a good thing that i started coding php again last night, otherwise i probably would have been too rusty to work it out
|
![]() |
|
| Jamie-ZNS | Apr 1 2005, 12:54 PM Post #7 |
![]() ![]() ![]() ![]() ![]() ![]()
|
Well, ;'s tend to be evil and often run away so you forget about them. |
![]() |
|
| Rory | Apr 1 2005, 12:59 PM Post #8 |
|
i;m a mess
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]()
|
indeed... down with ;'s. we should just remove all puntuation. |
![]() |
|
| Jamie-ZNS | Apr 1 2005, 01:02 PM Post #9 |
![]() ![]() ![]() ![]() ![]() ![]()
|
That would be so much easier Maybe a little confusing because Im not using any punctuation and its a little hard to understand >_< |
![]() |
|
| 1 user reading this topic (1 Guest and 0 Anonymous) | |
| « Previous Topic · Technology Chat · Next Topic » |
| Track Topic · E-mail Topic |
8:49 PM Jul 10
|



![]](http://b1.ifrm.com/0/1/0/p601690/pipright.png)



saves the day again!! And quickly as well!
8:49 PM Jul 10