Results 1 to 2 of 2

Thread: Display most visited page on the homepage?

  1. #1
    Join Date
    Apr 2007
    Posts
    1

    Smile Display most visited page on the homepage?

    Does anyone know how to make a link on the home page of a site that goes to the most visited page on the same site. Thanks

  2. #2
    Join Date
    Mar 2005
    Posts
    83
    Quote Originally Posted by peejeev
    Does anyone know how to make a link on the home page of a site that goes to the most visited page on the same site. Thanks
    If it was me, I would create a PHP script which would be added to every page, when a page is loaded it add's an entry into a database containing the pageID. Then when you want to work out the most visited page, create a script to pull the data from the database and count the number of times each page has been visited, that's your most visited page.

    You could create an entry in the database table for each page, then have a count field, and each time the page is displayed the count is retrieved from the databases and incremented by one. However this would cause problems when 2 people viewed the page at the same time. i.e. lets say the count for one of your pages is 20, the first person retreived the value and increments it by 1, so now it's 21, but before it gets chance to save the value back to the database someone else has viewed the page, retreived the count 20 incremented by 1 to make 21. This means that both pages will save the value 21 back to the database, but it should be 22.

    Hope that helps.

Similar Threads

  1. page won't display properly in IE
    By teamgod13 in forum Web Design, HTML Reference and CSS
    Replies: 1
    Last Post: 10 Mar 2006, 05:20 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •