2007 hyunai sonata

my car was making a loud i wanna say a rattling noise when i first started my car and then when i woud excellerate. i was driving to to work and while driving my car shut off. it wont start back up. i have power and spark. i dont know what is wrong with it