How to Build a PHP Auction Websiteby Haden Peterson
At a minimum, you'll want to create the following tables with the included fields: Items (title, description, reserve price, photo, id); Users (name, password, email address, credit card info type and number, shipping address); Bids (amount, item_id, bidder_email_id). These need not be created all at once. For example, you may want to create an Items table, populate it with sample data, and then develop the user interface to resolve any problems that arise.
Populate your tables with sample data. You can do this at the myself prompt, but a better way is to use a database wrapper such as PEAR DB (library of database functions) that will provide you access to basic create, read, modify and delete functions that any system needs. That functionality will enable an administrator to add, modify and delete items as needed.
Display your data. Initially, you'll probably want to show all items to viewers of your site. Later, you can constrain items by assigning them to a category. Best practice emphasizes isolating functionality from presentation and you'll do this by creating a controller (index.php) that will contain the logic for handling actions (registering a new user, authenticating users, accepting a bid) that you want to provide.
The presentational aspects of the site will be handled by a view template, which will contain the HTML and CSS that determines, for example, the properties of each item (color, font, size) as well as its position on the page. This template will be invoked by the controller as needed.
Create the bid logic. When users bid on an item, check that they're authenticated and that their bid is higher than the last accepted bid (or reserve, if there are no bids). If so, store their bid in the bids table.
Items you will need
- LAMP stack: OS (Linux, Windows, Mac OS X), Web server (Apache, IIS), MySQL, PHP 5