0

I have account funds table in wordpress database. Structure like this;

Id           user_id         fund_user        type_operation
-----------------------------------------------------------
1             1379               100              admin_op
2             1565               500              admin_op
3             1379              -50               pay
4             1379               200              admin_op
5             1616              -150              pay

And in my Wordpress page, I want to display the following:

Loggedin user's only admin_op in type_operation, GET TOTAL only positive fund_user values.

I have this;

global $wpdb; 
$result_good = $wpdb->get_results("Select sum(fund_user) as good_points from wp_ywf_user_fund_log where type_operation='admin_op'");

        $haha= "Total Points for Good =".$result_good['good_points'];
        echo $haha;
        return $haha;

but that result none and i cant edit that for my specific query.

How can i get and echo in that table, for current user, specific type_operation's Total of fund_user's value?
Thanks for all replies.

0

If it's no extricly neccesary perform an operation in a sql statement I would prefere perfom it over an Array of admin_op data, like : op_sum = get_results( Select fund_user FROM table WHERE type_operation = admin_op ); then var = array_sum(op_sum);

|improve this answer|||||

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.