Good evening, I'm on a project where I have to make a site that allows users to recommend movies, and then show them the most recommended ones.
I've already done the recommend system, now I need to make the most recommended list.
The system works like this:
The user recommends a movie and this data goes to a column of a table, I want to make the system count the most repeated data of that column and show me the 10 most repeated.I have two doubts.
1. How to make sql count and organize the most repeated.
2. How to do an "ECHO" for table rows?
Thank you in advance:)
UPDATE !!!
Although I follow the code that you told me, errors appear in the code result, like this:
Warning: mysqli_query () expects at least 2 parameters, 1 given in /home/u313079178/public_html/index.php on line 62 Could not fetch Warning: mysqli_fetch_row () expects parameter 1 to be mysqli_result, null given in /home/u313079178/public_html/index.php on line 66
My code looks like this:
$result = mysqli_query("SELECT filme, COUNT(filme) FROM dados_rec
GROUP BY filme
ORDER BY COUNT(filme) DESC LIMIT 10");
if (! $ result) { echo "Could not fetch"; } $ row = mysqli_fetch_row ($ result);
echo $ row [0]; echo $ row [1];