[Solved] Create top ten list of items in php [closed]


To do this, first you must get the movies from the database and list them.

For example, a simple select-query that selects all the movies and shows them to the user using a while-loop.

$get_movies = mysqli_query("SELECT * FROM `movies`");

while($row_movies = mysql_fetch_array($get_movies);)
{
echo $row_movies['title'];
}

You then allow the user to rate the movies, using a select-box that you can show on the same row.

Now, when the user selects, say for example 4; you save that value to the database (using javascript to automatically post the form), and reload the page. The next time the list loads, the select-boxes contain every number from 1 – 10, except for 4 since it’s already been used. You can also use AJAX to do this.

Of course, you will need a column in the database that holds the rating of the movie. And also, to make sure that the correct row is selected, you can always create one form per row holding the ID of the movie in a hidden field.

To ensure that the user doesn’t cheat your script by de-activating javascript, you can always filter your script using PHP to make sure that there is only one form being sent, and to make sure that the ID actually exists in your database. And also, don’t forget to escape the strings used in your mysql queries.

solved Create top ten list of items in php [closed]