Assuming MySQL...
<?
$score = mysql_query("SELECT SUM(score), userid, name FROM score_table GROUP
BY userid");
mysql_query("DELETE FROM totalscore_table");
while (list($score, $userid, $name) = mysql_fetch_array($scores))
mysql_query("INSERT INTO totalscore_table (userid, name, totalscore)
VALUES ('$userid', '$name', '".addslashes($totalscore)."')");
?>
/* Chris Lambert, CTO - [EMAIL PROTECTED]
WhiteCrown Networks - More Than White Hats
Web Application Security - www.whitecrown.net
*/
----- Original Message -----
From: Martin Kampherbeek <[EMAIL PROTECTED]>
To: <[EMAIL PROTECTED]>
Sent: Sunday, August 19, 2001 5:34 AM
Subject: [PHP] Count total
Hi,
Who can help me with the following problem?
I have the tables score and totalscore.
Score:
id
userid
name
score
Totalscore:
userid
name
totalscore
In the table score one user can have mutiple scores. But in totalscore the
userid is unique. Now I want to count all the score's of a user en place
this at the same user in totalscore.
Example of score:
1 1 Martin 10
2 2 John 5
3 3 Richard 12
4 1 Martin 3
5 3 Richard 8
6 1 Martin 7
7 2 John 15
So I would like to know the total score of each user.
But I don't know how to do this. Who can help me out?
Cheers,
Martin.
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]