I can't tell you how it works, but it does work. I hope you are familiar with God's Word in the Bible and seek its knowledge daily. People fool themselves into believing that when times get bad, they can just say a simple prayer for a few weeks and all will be well. God hears every prayer, and answers every prayer, although not always in the ways we expect Him to. I am sorry for your heartache and struggle. I know that God has allowed this for a reason, and I also know He will use this experience to grow your faith and bless your life. It is hard to see the hope and future when tears are falling from your eyes and your heart is broken. But it is there....scripture is true and Romans 8:28 says, " And we know that in all things God works for the good of those who love him," while Jeremiah 29:11 promises, "For I know the plans I have for you," declares the Lord, "plans to prosper you and not to harm you, plans to give you hope and a future."
There are things all of us must do in order to receive answers to our prayers - cast away bitterness, confess our sin, forgive others, seek with a humble, repentant heart, and believe that we have received what we ask for. I pray that God will remove this sense of hopelessness from your life and open your spiritual eyes to the ways in which He is blessing you. May He walk with you through this trial and strengthen you in all ways.