Hmm.. your not going to learn much if people just give you code + this is homework.
My first question is how good is your PHP. Do you know the basics, how to connect to a database, how to do control statements (if/else switch etc).
If so a checkout isnt all too hard.
Basically
User x arrives and a session for user x is initiated as well as stored in the database. User x comes to the products page and adds a few products to there cart which are stored in cart table with the identifier as thier session as the as the quanitity, and the productid which the product is also stored in the database.
User x than wants to pay for their items and clicks on checkout.
A query looking something like this
SELECT products.name, products.productid, cart.*
FROM cart
LEFT JOIN products ON (cart.productid=products.productid)
WHERE cart.sessionid=$_SESSION['id']
The tables work look similar to this
Cart
cartid|sessionid|quanitity|productid
Products
productid|name|price
Sessions
sessionid|ipaddress
From the query a loop is needed to loop through all the items found in the query.
Here is where we add up the cost of
cost=quanitity*productCost
totalCost+=cost
l
totalCost is the total cost of all the products added together
cost speaks for itself basically quanitity times the products cost.
Then the user accepts whats in their cart and goes off orders it the items in there cart are now deleted
Hope that helps somewhat. I didnt code it for you but you should have some idea on what you need to get done