Jump to content

wierd counting problem


GRooVeZ

Recommended Posts

hi,

i wrote a pointsystem for a league,

everything is working good untill i do a certain math action

 

this is the piece of code where it goes wrong

 

$playerkills = '0';

$playerdeaths = '0';

 

$players3=mysql_query("SELECT playerid,matchid,roundid,kills,deaths FROM ffa_results WHERE playerid='$playeridcheck' and matchid='$matchidcheck'");

while(list($playerid3,$matchid,$roundid,$kills,$deaths)=mysql_fetch_row($players3))

{

$playerkills = ($playerkills + $kills);

$playerdeaths = ($playerdeaths + $deaths);

}

 

$playerkillsdeaths = ($playerkills - $playerdeaths);

 

$matchtypecheck=mysql_query("SELECT type FROM ffa_matches WHERE id='$matchidcheck'");

while(list($type)=mysql_fetch_row($matchtypecheck))

{

$matchtype = $type;

}

 

$matchskilllvlchecker=mysql_query("SELECT skill FROM ffa_matches WHERE id='$matchidcheck'");

while(list($skill)=mysql_fetch_row($matchskilllvlchecker))

{

$matchskill = $skill;

}

 

$skilllvlchecker=mysql_query("SELECT ffapoints FROM members WHERE id='$playeridcheck'");

while(list($skill2)=mysql_fetch_row($skilllvlchecker))

{

$playerskill = $skill2;

}

 

$schaal = round(($playerskill - $matchskill)*7);

$playerpoints = ($playerkillsdeaths - $schaal);

>>>>>>>>>>>>>>>>>>>>>>> $playerpoints2 = ($playerkillsdeaths - $playerpoints);

 

$insertSite_sql2 = "INSERT INTO ffa_points (matchid,matchtype,playerid,kills,deaths,killsdeaths,points) VALUES

($matchidcheck,$matchtype,$playeridcheck,$playerkills,$playerdeaths,$playerkillsdeaths,$playerpoints2)";

$insertSite2= mysql_query($insertSite_sql2);

}

 

everything works good untill the >>>>>>>> line, all math before that is working, i can insert all of those vars in the last field in the points collumn. but from the moment i do playerpoints - playerkillsdeaths it retursn me the $schaal variable, i dont have a clue why, but it does, for some kind of reason i cannot contracts those two vars ..

has this something todo with the line before the >>>> line?

 

who can explain this to me?

 

thanks allot in advance

 

Link to comment
Share on other sites

You forgot to tell us the actual values your code is using, what result you got, what result you expected, and exactly how you observed that the result is not what you expected.

 

Also, why are you looping over query results where there is only one row in each result set and executing two separate queries against the ffa_matches table just to get the type and skill values from the same row?

Link to comment
Share on other sites

hey man

i got this thing working now, but to answer ur question

im a php noob, and im more like copy pasting and puzzling then writing code myself :)

 

anyway ive been doing some research and this piece of code is really easy, but im failing ...

 

can u tell me what im doing wrong?

i just want to exec a query and then check if there was a result

 

$query10 = "SELECT points FROM ffa_rankings WHERE playerid='$playeridcheck' and gameid='$gametype' and typeid='$matchtype'";

 

$result10 = mysql_query($query10);

 

 

$row10 = mysql_fetch_array($result10);

 

 

if ($row10)

 

{

 

operation here

}

else

{

operation here

}

 

Link to comment
Share on other sites

What is happening when you run this code?

<?php
$query10 = "SELECT `points` FROM `ffa_rankings` WHERE playerid = '{$playeridcheck}' and gameid = '{$gametype}' and typeid = '{$matchtype}'"; 
$result10 = mysql_query($query10);
$row10 = mysql_fetch_array($result10);
if ($row10) { 
//
} else {
//
}

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.