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.
wpdb::get_results()
returns an array of row data (each is an object by default), so try with$result_good[0]->good_points
or usewpdb::get_var()
to retrieve a single result.