Jump to content

Help with substituting web script code


Chrisj

Recommended Posts

The original web script that I'm using calculates daily earnings from video purchase transactions. I have added my own videos purchase transactions code into this web script successfully, and I'm trying to integrate my successfully working code part in with the original web script's page - that displays the daily earnings. Here is (part) of the original web script's code:

    $day_start = strtotime(date('M')." ".date('d').", ".date('Y')." 12:00am");
    $day_end = strtotime(date('M')." ".date('d').", ".date('Y')." 11:59pm");
    $this_day_ads_earn = $db->rawQuery("SELECT SUM(amount) AS sum FROM ".T_ADS_TRANS." c WHERE `time` >= ".$day_start." AND `time` <= ".$day_end."  AND type = 'video' AND video_owner = ".$pt->user->id);
    $this_day_video_earn = $db->rawQuery("SELECT * FROM ".T_VIDEOS_TRSNS." c WHERE `time` >= ".$day_start." AND `time` <= ".$day_end." AND user_id = ".$pt->user->id);
    $day_net = 0;
    foreach ($this_day_video_earn as $tr) {
        if ($tr->currency == "USD") {
            $day_net = $day_net + ($tr->amount - $tr->admin_com);
        }
        else if($tr->currency == "EUR"){
            $day_net = $day_net + ($tr->amount - $tr->admin_com);
        }
    }
    $today_earn = $this_day_ads_earn[0]->sum + $day_net ;

The table they are using is T_VIDEOS_TRSNS, my modification stores video transactions in the table T_U_PAID_VIDEOS, and the earnings amount is stored in the 'earned_amount' column.

I'd like to substitute my code in, so the purchase transaction from my mod shows on the original web script's already set up page. I look forward to, and appreciate, any suggestions, or requests for more info/code.

Link to comment
Share on other sites

I think his point is, that you are basically asking someone to rewrite code to your specifications.  On a good day, with the right type of question, you might get people writing code for you, especially if there is something very interesting or challenging about it.  This is not one of those questions.

Basically, we need to see what you tried to do that didn't work.  As it is, you haven't tried anything yet.

Do some work, and come back with questions, and you might surprise yourself and fix it yourself.  ?

  • Like 1
Link to comment
Share on other sites

On 4/6/2019 at 9:55 PM, Chrisj said:

Thanks for your reply, but I'm not clear on what you are telling me.

Any help with substituting my code with the original script is appreciated.

I read your original post a couple times, and not sure what you are asking.  Maybe I needed to follow your earlier posts for reference?  Regardless, if you are trying to substitute one set of code with another, you need to figuratively draw a circle around it and understand (and even write down) how it interfaces to the remaining code, and then make sure your new code interfaces to the remaining code the same way.

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

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.   Restore formatting

  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.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.