Welcome!

By registering with us, you'll be able to discuss, share and private message with other members of our community.

SignUp Now!
  • Guest, before posting your code please take these rules into consideration:
    • It is required to use our BBCode feature to display your code. While within the editor click < / > or >_ and place your code within the BB Code prompt. This helps others with finding a solution by making it easier to read and easier to copy.
    • You can also use markdown to share your code. When using markdown your code will be automatically converted to BBCode. For help with markdown check out the markdown guide.
    • Don't share a wall of code. All we want is the problem area, the code related to your issue.


    To learn more about how to use our BBCode feature, please click here.

    Thank you, Code Forum.

PHP Can you help me confirm the purpose of this code?

chrisj

Bronze Coder
In this web script, that I'm trying to modify, it has this section of php code:

PHP:
$withdrawal_history = "";
if ($pt->setting_page == 'withdrawals') {
    $user_withdrawals  = $db->where('user_id',$pt->user->id)->get(T_WITHDRAWAL_REQUESTS);
    foreach ($user_withdrawals as $withdrawal) {
        $pt->withdrawal_stat = $withdrawal->status;
        $withdrawal_history .= PT_LoadPage("settings/includes/withdrawals-list",array(
            'W_ID' => $withdrawal->id,
            'W_REQUESTED' => date('Y-F-d',$withdrawal->requested),
            'W_AMOUNT' => number_format($withdrawal->amount, 2),
            'W_CURRENCY' => $withdrawal->currency,
        ));
    }
}

I know that T_WITHDRAWAL_REQUESTS is the withdrawal_requests db table. So, does this chunk of code appear to take the withdrawal request amount from the table and load it into the page that displays the withdrawal requests history?

If not, what is this code doing? If so, is it possible to modify this code here to change the amount displayed? Such as displaying half of the amount (that is populated in the withdrawal history table's amount column) into the page that displays the withdrawal requests history ?
 
$withdrawal_history = "";
This is just setting the history string to be blank, nothing.

if ($pt->setting_page == 'withdrawals') {
If we're on the page for withdrawals... let's access withdrawals:

$user_withdrawals = $db->where('user_id',$pt->user->id)->get(T_WITHDRAWAL_REQUESTS);
The user withdrawals array will hold data from the database table 'T_WITHDRAWAL_REQUESTS' which is a defined constant (so whatever that is), where the column user_id is the target user's id

foreach ($user_withdrawals as $withdrawal) {
Loop through each found result from the query above.

$pt->withdrawal_stat = $withdrawal->status; $withdrawal_history .= PT_LoadPage("settings/includes/withdrawals-list",array( 'W_ID' => $withdrawal->id, 'W_REQUESTED' => date('Y-F-d',$withdrawal->requested), 'W_AMOUNT' => number_format($withdrawal->amount, 2), 'W_CURRENCY' => $withdrawal->currency, ));
This code is pulling a view (loadpage) that is a withdrawals list, and it's inserting data from the current row (in the foreach loop) of data it found. So it's probably constructing a <tr> HTML row or something.
 
Last edited:
is it possible to modify this code here to change the amount displayed? Such as displaying half of the amount (that is populated in the withdrawal history table's amount column) into the page that displays the withdrawal requests history ?

'W_AMOUNT' => number_format($withdrawal->amount / 2, 2),
Pretty sure you can just do the / 2 part after $withdrawal->amount and it's good to go if you want to show half amounts!
 
Back
Top Bottom