M
M
masterwen2020-05-08 15:16:47
PHP
masterwen, 2020-05-08 15:16:47

How to output one bd value in a formula?

There is such a code, everything works if you substitute a number in place of ###. BUT I need to substitute the "sport1" value of each user there to calculate the percentage.

$tomat1 = ####;
        $prs1=$tomat1*100;
        $prsport1= $prs1/sprintf($stats_data["all_sport1"]);
        $prsc1=sprintf($stats_data["all_sport2"])/100;
        $prsport11 = $prsc1*$prsport1;
        $db->Query("UPDATE db_users_b SET money_b = money_b + $prsport11 ");
        
        echo "<center><font color = '#914A1F'><b>роздано победителям 1 </b></font></center><BR />";

Answer the question

In order to leave comments, you need to log in

1 answer(s)
Q
qfake, 2020-05-09
@qfake

few inputs.
if users are stored in the database, then something like this:
$users = User::find()->... (parameters for querying users from the database)
suppose one user is

$user = ['name' => 'имя', ..., 'sport1' => 'какое-то число'];

foreach ($users as $user) {
$tomat = $user->sport1;
//и далее все, что нужно сделать с этой переменной
}

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question