OK,
I think you've already been told the exact syntax problems in your code, so no need to repeat those here.
What might be worth thinking about now is how you go about debugging your code. If you have a chunk of code which doesn't work, you need to keep breaking it down into smaller slices to see how much of it works.
If it throws up error messages, read them. They are there to help you. If you read them and don't understand, type the error message into your favourite search engine and see if that shows up anything. If that doesn't get you anywhere, paste the code and the error message here, and see if anyone else can show you the syntax error.
If it doesn't throw up syntax errors, you can fall back on inserting "echo" commands into your code. These will help highlight which areas of your code are being run, which aren't and what the value of key variables are at certain points.
Judging by your post and response. I would imagine that you're not just new to PHP but that you're new to programming in general. Welcome aboard. It can be a very rewarding career or hobby.