FRIHOSTFORUMSFAQTOSBLOGSDIRECTORY
You are invited to Log in or Register a Frihost Account!

Ranking system

 


OldmanJ
Does anyone know if it would be possible using PHP and MySQL to have a webpage, with a list of items on it, where a person could click on one of the items in the list to vote for it.

The list would display in order of votes. One requirement would be to allow only one vote per IP on that specific page. Does that sort of thing sound possible with PHP and MySQL? Does it sound difficult?? If you could point me toward any resources/topics to help with designing such a system, that would be awesome!
hexkid
OldmanJ wrote:
Does that sort of thing sound possible with PHP and MySQL? Does it sound difficult??

Yes, it sounds possible and easy.
But relying on IPs is not a good thing to do (some people may change IPs even from one request to the next).

OldmanJ wrote:
If you could point me toward any resources/topics to help with designing such a system, that would be awesome!

http://www.php.net/manual


To help you start here's a snippet:
Code:
<?php
/*
I'm assuming data comes from a POSTed form where the items are in a select box or a bunch of radio buttons called "vote".
*/

if (isvalid($_POST)) {
  $ip = $_SERVER['REMOTE_ADDR'];
  if (isset($_SERVER['FORWARDED_FOR'])) $ip = $_SERVER['FORWARDED_FOR'];
  // I'm allowing people to change their vote
  $sql1 = "delete from datatable where ip='$ip'";
  $sql2 = "insert into datatable (ip, vote) values ('$ip', $_POST['vote'])";
} else {
  exit('Invalid vote. Go back and try again.');
}
?>
OldmanJ
That's awesome, thanks. Razz
Diebels
OldmanJ wrote:
Does anyone know if it would be possible using PHP and MySQL to have a webpage, with a list of items on it, where a person could click on one of the items in the list to vote for it.

The list would display in order of votes. One requirement would be to allow only one vote per IP on that specific page. Does that sort of thing sound possible with PHP and MySQL? Does it sound difficult?? If you could point me toward any resources/topics to help with designing such a system, that would be awesome!


Hallo there a plenty of Ranking Scripts around... you could try this:
http://www.aardvarktopsitesphp.com/

Wink
Reply to topic    Frihost Forum Index -> Scripting -> Php and MySQL

FRIHOST HOME | FAQ | TOS | ABOUT US | CONTACT US | SITE MAP
© 2005-2007 Frihost, forums powered by phpBB.