I am currently making a website that host free flash games. like kongregate.com. I however have a dilemma. I want to create a 5 star rating system which can display the quality of the games as voted by the user. I would also like a list to display both these things.
The things i think it needs to do are:
* gather the amount of hits from every page
* gather the star rating from every page
* sort the values into the numerical order where the highest is top
* list the first 20.
The easiest way I can think of to do this would be to utilize a MySQL database. Create a table called 'pages' (can be replaced with game) with the fields: page_id, page_name, page_hits, page_rating. Then just update the pages using php as I need (e.g. increment page_hits when a user enters that particular page).
I spoke to a friend who said the code for requesting the database should look something like this
function recordHit($page)
{
// Connect to db code here
// Clean database input
$page = mysql_real_escape_string($page);
// Update the database
$res = @mysql_query("UPDATE tblPages SET hits = (hits + 1) WHERE name = '$page'");
// Close DB code here
return ($res);
}
I'll then need a PHP page that requests the pages from the database in the order of most popular or highest rating. You can then use PHP to list these in some way.
The things i need help with are:
1. creating a star rating system
*adding all values enetered by the user and averaging
*stopping a user from rating more than once
*sending/updating that value in the database
2. creating a hit system
*counting page hits
*updating the database with the value
3. requesting 20 database values
*requestign 20 database values
*listing 20 database values in numerical order
If you could help me find a way to do this, I would be extremely greatful. example code is great but im also looking for tutorials and explanations. thank you.