The code you've shown looks fine, but since we have know way of knowing what the value of $total or $select_member['cash'] is, we have no way of knowing what the result should be. If you are not getting the expected result, then try doing a var_dump() of each variable to see what their values really are versus what you think they are.