Before we begin we need to create a MySQL database table to hold the ratings information. We are only creating four fields: a unique ID, the name of what we are rating, and 2 columns to hold voting information. You can create more fields if needed, for example if you are rating photos you may want to include the photos URL, the author, a description, etc etc.
We will also need to put some data into the database to work with. You could use this tutorial if you wanted to add new information directly from your browser, however here we will assume you already have a method in place for adding new options. The SQL below will just fill in the table with some sample data to work with.
CREATE TABLE vote (id INT(4) NOT NULL AUTO_INCREMENT PRIMARY KEY, name VARCHAR(30), total INTEGER, votes INTEGER)
INSERT INTO vote (name, total, votes) VALUES ( "First item", 45, 10 ), ( "Second item", 15, 4 ), ( "Third thing", 25, 7 ), ( "The Forth", 20, 5 ), ( "Fifth Thing", 0, 0 )