Search code examples
phpjavascriptjquerycodeigniter

marking read articles


I have an app that displays external links to a site, they are all articles. These articles are in the database. I'm currently looking into a solution that would show the user new articles on their next visit, via a simple tag like "NEW" etc.

I have made a table with cols ID, user_id, article_id, read.
I have started work on the models and controller but basically I need to pass the article ID and user ID to a jQuery function when a user clicks that article so that the data can be inserted into the data showing that the article has been read. Thus the "NEW" label would not be shown for that article anymore.

Is this the best way to do this? I need some help on how to approach the jQuery side of things.

Thank you.


Solution

  • Building on what sawny said, you won't need another controller. Just define a function in your controller to handle this

    baseurl.com/controller/function/linkID

    In the function you'll want to make sure that you store the Artilce ID and User ID in a seperate table.

    Table Name: article_views Fields: userID, articleID

    That way you can join on this table to help you display which articles are infact new for each user.

    Once that's been store you can redirect the user to the actual article.