By "it's not working", do you mean it's just not giving you what you expected? Or throwing an error?
I'd be inclined to suggest that you remove the ; in the query, since it's irrelevant in this sort of approach.
I'd also suggest changing $order->customer['customers_id'] to $_SESSION['customer_id']
I'd also remove the else { $check_flag = false;} part of your if statement.



