I am developing an API using Codeigniter and in this API the users can tag
themself. I need to display the 10 most popular tags (most frequestly used tags).
How can I do that?
Update
The tag table contains:
id, user_id, tag, created_at, updated_at
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
Jonathan, depending on your setup the solution will be different, I’m going to suggest something a bit different than what your table structure looks like, you can use it if you want to.
To add a tag to your database:
$data = array(‘tagName’ => ‘Mr. Niceguy’);
$this->db->insert(‘tags’ => $data);
To add a tag to your user, you could use the following in a model
To recieve the most common used tags:
Edit:
If you have to use your setup, do this instead: