View Full Version : Quiet Difficult to do ?

05-29-2004, 11:55 PM
Hi there ,

I have a problem that I donno how to write this in PHP.
First I have this Function that I wrote to calculate points from a given value out of a Table Field from MySql.

//what score function

function what_scores($amount_what) // Send in how many what points in the function.
$points = $amount_what;
$what[1] = $points-1;
$what[$i] = round($catres[$i-1] * 0.95,1);
return $what; // Returns an array with the scores, $what[1] - $what[10]

Now the problem that I have is how do I do i write a form that get the value from a field out of a other table lets say value 100 and check in the form first what place it has so lets say ( for example ) player 1 is ranked 2 and the value is 100 so 100 -1 then 95% , (place 2=) 90% etc etc ? and if course write the outcome of this back into MySql field. So place 2 is 100 and -1 and 90% of the first calculation of -1 =99 and the -5% as showen in the function !.
I hope some is clear as it is quiete hard to explain :)

Or other option that I could use is to read the place lets say 2 of the field in sql and then do the calculation and show it as query based on the same function !.

Thx in Advance


06-01-2004, 03:12 PM
still a bit confused by your question....

basically are you wanting to create a kind of "top 10" script?
by that i mean it takes a value in (say 95%) compares it to the list and inserts it at the right point (say number 3 out of 10)


06-02-2004, 12:24 PM
Hi Sweenster , thx for the reply.

Well as I said before its a bit confusing of what I wrote as it is quiete hard to explain , as I said.

Ok I will be a bit more clear to this.

I have a Table called "counts"
In that table 2 field's

Now I have a value in count where the value of 100 ( for example ) is stored before by entering the player details so Player = Place 6 now I want that the function before grab the value of 100 and do te calculation en return it in a echo to show the results , now what happen now with the current function is that it shows the outcome 1 trough 15.
What I want that the function look what place the player has then calculate the value of 100 and return it into the echo.
Problem might be is the value of 100 for the First Place = -1 so it starts with 99 and then calculate -5%.

Its a bit different as my first question but I would like aswell that I can update or insert it with a form so I could add a field with total and the make a top 10 or better top 15 of the players.

Hope its clear now ? :)