Yes, it can be done and has been done. You have a few options.
1) Write your own. If you go this route, dig into the PHP and MySQL Manuals and once you get the code together, come back here and post for whatever help you need in tweaking it.
2) Use a premade Cart system. You can go to hotscripts.com and peruse their goods to see if you find one you like. (You can usually tweak these to better suit your needs, but at least you aren't reinventing the wheel.)
If you are wanting to do some learning, then start with some smaller items like counters, polling systems, etc. and work your way up to make a shopping cart. It will take you some time, but if time isn't that important, but learning is, this is the best thing to do (rather than jumping both feet into a major undertaking like a shopping cart).