Every income deduct certain amount

 If you want to implement a deduction of 10 Rs for every 100 Rs income in an MLM system using PHP, you can modify your calculation logic to incorporate this deduction. Below is a basic example:


```php

<?php

// Assuming you have a user_id, total_income, and deduction_amount columns in your user table


$user_id = 1; // Replace with the actual user ID


// Fetch the user's total income

$sql_fetch = "SELECT total_income FROM user WHERE user_id = $user_id";

$result_fetch = $conn->query($sql_fetch);


if ($result_fetch && $row = $result_fetch->fetch_assoc()) {

    $total_income = $row['total_income'];


    // Calculate the deduction based on every 100 Rs

    $deduction_amount = floor($total_income / 100) * 10;


    // Apply the deduction

    $total_income_after_deduction = $total_income - $deduction_amount;


    // Update the user's total income with the deducted amount

    $sql_update = "UPDATE user SET total_income = $total_income_after_deduction WHERE user_id = $user_id";

    if ($conn->query($sql_update) === TRUE) {

        echo "Deduction applied successfully.";

    } else {

        echo "Error updating total_income with deduction: " . $conn->error;

    }

} else {

    echo "Error fetching total_income: " . $conn->error;

}

?>

```


This code checks the user's total income, calculates the deduction based on every 100 Rs, and updates the user's total income after deducting the calculated amount. Make sure to adapt this code to match your specific database structure and logic.

Previous
Next Post »