1
Good evening, I’m on a project where I should make a site that gives users to recommend movies, and then show the most recommended ones.
I already made the system to recommend, now I need to make the list of most recommended.
That’s how the system works:
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 this column and show me the 10 most repeated. I have two doubts.
1.How to make sql count and organize the most repeated ones.
2.How to make an "ECHO" for table Rows?
Thank you in advance :)
UPDATING!!!
Although I follow the code you told me, errors appear in the result of the code, like this:
Warning: mysqli_query() expects at least 2 Parameters, 1 Given in /home/u313079178/public_html/index.php on line 62 Could not perform search 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 is 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 perform search"; } $Row = mysqli_fetch_row($result);
echo $Row[0]; echo $Row[1];
Thank you very much friend, I knew about this Count but I didn’t know how to use or organize the Rows, thanks.
– Luvinicius
I edited the question, some unexpected errors appeared, have to help me?
– Luvinicius
You have to pass the connection as the first argument of the mysqli_query function. thus: $mysqli = new mysqli("localhost", "my_user", "my_password", "world"); $result = mysqli_query($mysqli, $sql);
– Júlio Neto