I think you find the answer in Kevin Jank's book:
Build Your Own Database Driven Website Using PHP & MySQL chapter 6. If you buy the book, you also get the code. I think all you need is minor rewrites.
I warmly recommend the book. I bought it from USA, and it was in my hands, less than a week later. By reading that chapter you should also know what is going on. Check boxes or similar to a(n) category array and PHP variables given content via the array? May be you need the PHP function, htmlspecialchars, if you have escape characters in your queries etc.
If you make it
OO, you may even make a connection class. Then you can use the same PHP code independent of database server.