Hi Mandy,
Some one maybe able to advise better but you can get the train from Alhama to Murcia, think every 10 minutes past the hour ( free parking) ,then train to Madrid from Murcia. Not done it ourselves but i believe you can pre book tickets on the Renfe site, they also offer special online deals