Page 1 of 1

show the votes on my website?

Posted: Mon Oct 25, 2004 1:55 am
by masomehs
Hi!

i just created a poll(voting script).
and i want the script to show how many that have voted:
example:

Votes
Nice page: 20 votes
Ugly page: 15 votes

The poll is connected to the database and work perfectly , when you vote it saves in the database. but i dont know how to do so it shows in the website how many votes there is. and i want them to only vote once! not many times. i guess i must use Cookies for that. i could need some help with that to.

Well, here is the code:

Code: Select all

<?  
if(isset($_POST&#1111;'vote'])) &#123;  
echo "Du röstade på alternativ nummer ".$_POST&#1111;'vote'];  
&#125;  
$sql = "UPDATE vote SET roster=roster+1 WHERE alternativ=$_POST&#1111;vote]";  
include_once 'connect.php';  
mysql_query($sql);  
?>
If you need the html code to, just tell me =).

Thanks, Masomehs

Posted: Mon Oct 25, 2004 2:13 am
by timvw

Code: Select all

select sum(roster) from vote
allowing people to vote only once could be done with cookies (although they might delete the cookie and vote again.) you could also require them to login and then store if they already voted.