CURRENT_TIMESTAMP AND s.customer_id = c.customer_id)"; elseif ( $sort == "4" ) $str .= "WHERE c.active = 'Y' AND EXISTS ( SELECT expiration_date FROM subscriptions s WHERE s.expiration_date > CURRENT_TIMESTAMP AND c.customer_id = s.customer_id)"; elseif ( $sort == "5" ) $str .= "WHERE c.active = 'N'"; $str .= "ORDER BY c.customer_name"; $result = mysqli_query ( $GLOBALS['__mysqli_conn'], $str ); check_for_mysqli_error($GLOBALS['__mysqli_conn']); ?>