S
|
scoobysteve author 6/8/2012 |
Hi I am creating a scoring system for my members based on content and image uploads etc, the following code works fine by adding the scores into the fields named score1-score11 the total is then worked out by summing these up and then that amount is written to another field TotalScore. Now its all working in the After successful logon BUT to get the TotalScore updated I have to logon twice with the same userID, I am guessing thst its because after the scores have been written the next piece of code has not successfully obtained the data from the database so returns 0 but then next time it can see the totals, if someone can help I would really appreciate it. Here is the code used if(!isset($data['Spare2']) || trim($data['Spare2'])==='') { global $conn; $strUpdate = "update tblproperties set score11='0' where UserName='".$_SESSION["UserID"]."'"; db_exec($strUpdate,$conn); } else { global $conn; $strUpdate = "update tblproperties set score11='100' where UserName='".$_SESSION["UserID"]."'"; db_exec($strUpdate,$conn); } $DesCount = count(explode(" ",$data['Description'])); global $conn; $strUpdate = "update tblproperties set score9=$DesCount where UserName='".$_SESSION["UserID"]."'"; db_exec($strUpdate,$conn); $ModsCount = count(explode(" ",$data['ListMods'])); global $conn; $strUpdate = "update tblproperties set score10=$ModsCount where UserName='".$_SESSION["UserID"]."'"; db_exec($strUpdate,$conn); This is the bit that has to run twice on this event below in order to get the right results global $conn; $sum_total = ($data['score9']) + ($data['score10']) + ($data['score11']); $strUpdate = "update tblproperties set TotalScore=$sum_total where UserName='".$_SESSION["UserID"]."'"; db_exec($strUpdate,$conn);
|
S
|
scoobysteve author 6/8/2012 |
Any thoughts on this anyone please, I am so close but right now I cant use it until it updates the TotalScore on the first login Thanks Steve
|