Chest X-ray clear, blood in phlegm is now gone but have upper back pain. If it was lung cancer would it have shown on x ray? Having anxiety!

Not always. A chest x-ray can miss lung cancers, especially if they are early/small, when they can be best treated. Although it is not likely you have lung cancer given your age, please see your health care provider and get further evaluation. A chest ct would be a better test for lung cancer depending on your specific situation, but we want to limit radiation exposure, so benefit needs to outweigh risk.
How long ago? It takes a month or so to get over bronchitis and pneumonia and clear lung and x-ray longer if smoking! ct is a better test to rule out lesions of lung. Get checked so you can move on!