Page 1 of 1
Most Popular / Related Articles
Posted: Wed Aug 08, 2007 2:20 pm
by greenyeyes26
Hi there
i have a problem building a site with news
table news
news_id, news_title, news_date, news_category
now, i want to present the 5 most popular articles based on clicks (views) of every article in a place of the main page.
The page that displays the articles is e.g. article.php?news_id=453
Also, i need to find a solution to present the 5 most related articles to the one is viewed.
Please ... urgent need for help ...
Posted: Wed Aug 08, 2007 3:36 pm
by feyd
- Your query would sort based on view count
- Your query would use keyword linking. It can be fairly complicated.
In either respect, this has almost nothing to do with PHP specifically.
More specifically
Posted: Wed Aug 08, 2007 3:56 pm
by greenyeyes26
Thanks for help ..
I'm just trying to find how i will implement this view count for the last 7 days ... (for the most popular)
Posted: Wed Aug 08, 2007 4:17 pm
by feyd
You'll need to log date and time requests for each page. Depending on how you want to do it, a query could either update an aggregate count column in another table with the current information, or the query to aggregate the information could be done live. Personally, I would go with the former over the latter.
Trying to get out of chaos ...
Posted: Wed Aug 08, 2007 4:23 pm
by greenyeyes26
Thanks friend ... I just don't know the code to log the date and time of the articles. I could go for the first solution also .. if i knew the way
Thanks again...
Posted: Wed Aug 08, 2007 4:40 pm
by feyd
There are several ways to get the current date and time information. One being date() and another being from the database you are using. There isn't a wrong choice here, only preference. If you're hoping for me to post some code, you'll be disappointed.
Thanks
Posted: Wed Aug 08, 2007 4:45 pm
by greenyeyes26
thanks anyway friend
Posted: Wed Aug 08, 2007 4:46 pm
by superdezign
Hehe.
You could just use the separate table that logs the date and article / page, and then just increment the view count for each day. You could also use that to delete outdated information as well.
A good table structure would be a page / article id, a date, and a view count. Simple.