Jump to content
php.lv forumi

Nesaprot kapēc viņš man neizsaka vidējo reitingu


nascar

Recommended Posts

Sveiki tātad

 

pašreizejais kods

 

if($my_rating == 10)
$my_rating = 10;
else
$my_rating = format_number($user['uzvaras'] / $user['pagarinajuma_zaudejumi'] / $user['zaudejumi'] * 10, 2);

 

Kapēc man stāv visu laiku 0, kautvai ir 1 uzvara un 0 zaudes, attiecigi es domaju ir jabut 10, un ja ir kads zaudejums tad protams ir vinam jaizvelk videjo skaitli, bet tas nenotiek... kapēc?

 

Paldies, Kaspars!

Edited by nascar
Link to comment
Share on other sites

nu jā rīta dumjā galva, bet cik citur manijis biju tad

ja ir viena uzvara tad uzreiz 10 uzlec man ta vajg, ā un errors

 

Warning: Division by zero in 411 line

 

$my_rating = number_format($user['uzvaras'] / $user['pagarinajuma_zaudejumi'] / $user['zaudejumi'], 2);

 

vienalga neaiziet man šorīt :[

 

===

 

EDIT:

 

tagad error nemet

 

$my_rating = number_format(($user['otl'] + $user['l']) / $user['w'], 2);

 

Bet rāda ķipa 0, bet pēc principa ta nevajdzetu but...

Edited by nascar
Link to comment
Share on other sites

nū, Tavs reitings: 0.00 (0-0-2)

pirmā 0 ir uzvaras - pagarinājuma zaudejumi - zaudējumi

 

un 0 šini gadijuma nedrikst but, tur ir jaiet mīnusos skaitlim, līdz -10 maksimālais!

 

$my_rating = number_format($user['w'] / ($user['otl'] + $user['l']), 2);

Link to comment
Share on other sites

Te pat nav pie vainas php zināšanas, bet gan jaatceras matemātika...

Hmm kā jau te teica ar 0 nedalās nekas...

Ja pareizi sapratu Tavu vajadzību tad

if ($user['w']==0) {$my_rating = 0;}
else {
$speles_kopa =$user['w'] + ($user['otl'] + $user['l'];
$my_rating = number_format(10/$speles_kopa*$user['w']), 2);
}

Maybe var kautkā skaistāk šo izteikt, bet šim vajadzētu strādāt, un reitings būs līdz 10 max

Edited by andism88
Link to comment
Share on other sites

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.   Paste as plain text instead

  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.

Loading...
×
×
  • Create New...