<?php // Connects to your Database //We only run this code if the user has just clicked a voting link if ( $mode=="vote") { //If the user has already voted on the particular thing, we do not allow them to vote again $cookie = "Mysite$id"; { } //Otherwise, we set a cooking telling us they have now voted else { //Then we update the voting information by adding 1 to the total votes and adding their vote (1,2,3,etc) to the total rating } } //Puts SQL Data into an array //Now we loop through all the data { //This outputs the sites name //This calculates the sites ranking and then outputs it - rounded to 1 decimal $current = $ratings[total] / $ratings[votes]; //This creates 5 links to vote a 1, 2, 3, 4, or 5 rating for each particular item } ?>
Wczesniej dodalem do bazy danych :
CREATE TABLE vote (id INT(4) NOT NULL AUTO_INCREMENT PRIMARY KEY, name VARCHAR(30), total INTEGER, votes INTEGER)
oraz
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 )
Na stronie wszystko sie wyswietla, ale skrypt nie liczy sredniej, po kliknieciu nic sie nie zmienia:
Adres do skryptu http://www.muzycznalista.yoyo.pl/
Prosze o pomoc.
Pozdro