Hey, I have a search feature that searches for words in my database.
I am currently storing all searches that users make in a table called `search`. I need to list the top 10 words that are searched for the most, excluding common words like "the, and, or, etc".
Because the searches users make are stored into a table, it should be fairly easy.
Could anyone give an example of how to do this?

Here's how my sql table looks:

table name: search

columns:
id (autoincrement)
phrase
date
resultsfound
ip

You have a phrase in the table, yet you want to list per word, is that correct ?

You have a phrase in the table, yet you want to list per word, is that correct ?

Yes, that is correct. I want to display the top 10 most searched words in order

In a mysql query you can group by phrase and count them, but then you would have to split them further in PHP.

select phrase,count(*) as phrasecount from search group by phrase

In PHP you would then loop through the results and generate a new array. But that depends on how you want to count the words in the phrase.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.