1

I have 75000 ₺ prize. I want to give prize by prize type:

1 Full ticket = 9 result

2 Half ticket = 14 result

3 Quarter ticket = 201 result

$total = 75000;
$sql = $db->query("SELECT * FROM winners WHERE sayisi='5'");

while($list = $sql->fetch_object()) {

        echo ($list->bilet_id)." - ";
  echo ($list->client_id)." - ";
        echo ($list->odultipi)." - ";
  echo " ODUL: ". floor($total / $sql->num_rows)."<br>";

}

When I write this code, it's giving a fixed result for all clients.

I want to give like this result

For Full ticket 9 client = 334 ₺ (3.006 ₺)

For Half ticket 14 client = 167 ₺ (2.338‬ ₺)

For Quarter ticket 201 client = 84 ₺ (16.884‬ ₺)

Totally 75000₺ should be result. How can count I this with math? I need your help.

https://i.stack.imgur.com/NbH22.jpg

2 Answers2

0

Add up the number of Full tickets:

$9$ Full tickets
$14$ Half tickets = $7$ Full tickets
$201$ Quarter tickets = $50.25$ Full Tickets

This gives a total of $66.25$ Full tickets. So each Full ticket should be worth $75000\;₺\;/\;66.25\approx 1,132.07547\;₺$. If you round this up to $1,132.08\;₺$ (which luckily is divisible by $4$), it will cost you an extra $30$ kuruş.

TonyK
  • 64,559
0

i solved.

Here my codes.

$total = 75000;
$sql = $db->query("SELECT * FROM kazananlar WHERE sayisi='5'");
$tam = $total / $sql->num_rows; // If normal count num rows for all

while($list = $sql->fetch_object()) {
        if($list->odultipi == "1") {
   $sonuc = $tam;  // If 1=Full Ticket  give $tam result.
  }
  if($list->odultipi == "2") {
            $sonuc = $tam / 2;  // If 2=Half Ticket  give $tam / 2 result.
  }
  if($list->odultipi == "3") {
            $sonuc = $tam / 4;  // If 3=Quarter Ticket  give $tam / 4 result.
  }
  echo ($list->bilet_id)." - ";
        echo ($list->client_id)." - ";
  echo ($list->odultipi)." - ";
        echo " ODUL: ". floor($sonuc)."<br>";

}

if somebody need can use like this. Thank you for your care.