Most Viewed PHP Tutorial

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Alec

    Most Viewed PHP Tutorial

    I am starting the creation of a simple news website in PHP, and would
    like to include a section for the 'most viewed' or 'most popular'
    articles.

    As a beginner to PHP, I have looked on google for such tutorials but
    to no avail.

    Does anyone here know of one?

    Many thanks,

    Alec
  • Jerry Stuckle

    #2
    Re: Most Viewed PHP Tutorial

    Alec wrote:
    I am starting the creation of a simple news website in PHP, and would
    like to include a section for the 'most viewed' or 'most popular'
    articles.
    >
    As a beginner to PHP, I have looked on google for such tutorials but
    to no avail.
    >
    Does anyone here know of one?
    >
    Many thanks,
    >
    Alec
    >
    You can either control the downloads yourself and increment a database
    counter when a particular article, or you can parse your web server logs
    to find out how many times a page has been accessed. Either works fine.

    --
    =============== ===
    Remove the "x" from my email address
    Jerry Stuckle
    JDS Computer Training Corp.
    jstucklex@attgl obal.net
    =============== ===

    Comment

    • Krustov

      #3
      Re: Most Viewed PHP Tutorial

      <comp.lang.ph p>
      <Alec>
      <Tue, 19 Aug 2008 04:10:54 -0700 (PDT)>
      <d19acc8e-19fa-42a2-8328-75e759501593@v5 7g2000hse.googl egroups.com>
      I am starting the creation of a simple news website in PHP, and would
      like to include a section for the 'most viewed' or 'most popular'
      articles.
      >
      As a beginner to PHP, I have looked on google for such tutorials but
      to no avail.
      >
      Millions of users have looked for avails on the internet and as far as i
      know nobody has ever found one .

      But what you could do is use a simple hidden hit counter to keep track
      of how popular a news story is .

      After that - its just a matter of how often you want to calculate and
      sort the news storys into a top ten list - or whatever .


      --

      Comment

      • Jeff

        #4
        Re: Most Viewed PHP Tutorial

        Jerry Stuckle wrote:
        Alec wrote:
        >I am starting the creation of a simple news website in PHP, and would
        >like to include a section for the 'most viewed' or 'most popular'
        >articles.
        >>
        >As a beginner to PHP, I have looked on google for such tutorials but
        >to no avail.
        >>
        >Does anyone here know of one?
        >>
        >Many thanks,
        >>
        >Alec
        >>
        >
        You can either control the downloads yourself and increment a database
        counter when a particular article, or you can parse your web server logs
        to find out how many times a page has been accessed. Either works fine.
        Just to add a bit to Jerry's remarks...

        There's probably dozens of ways to do this. Although it is so easy
        and ubiquitous to use a database, you can also just open a file and
        either increment it or append a new line. The old hit counter trick was
        to use a fake 1 pixel image:

        <img src="path_to_hi t_counter_scrip t" height="1" width="1" alt="" />

        That works for static pages as well. Since you are probably serving this
        from a database, the database hit counter is probably the easiest to
        implement. If you add a timestamp and insert each entry you can fake
        your own easy to read server logs. Parsing the real server logs can be a
        tough task for a relative newbie.

        Google "PHP Hit Counter".

        Jeff
        >

        Comment

        • Jerry Stuckle

          #5
          Re: Most Viewed PHP Tutorial

          Jeff wrote:
          Jerry Stuckle wrote:
          >Alec wrote:
          >>I am starting the creation of a simple news website in PHP, and would
          >>like to include a section for the 'most viewed' or 'most popular'
          >>articles.
          >>>
          >>As a beginner to PHP, I have looked on google for such tutorials but
          >>to no avail.
          >>>
          >>Does anyone here know of one?
          >>>
          >>Many thanks,
          >>>
          >>Alec
          >>>
          >>
          >You can either control the downloads yourself and increment a database
          >counter when a particular article, or you can parse your web server
          >logs to find out how many times a page has been accessed. Either
          >works fine.
          >
          Just to add a bit to Jerry's remarks...
          >
          There's probably dozens of ways to do this. Although it is so easy and
          ubiquitous to use a database, you can also just open a file and either
          increment it or append a new line. The old hit counter trick was to use
          a fake 1 pixel image:
          >
          <img src="path_to_hi t_counter_scrip t" height="1" width="1" alt="" />
          >
          That works for static pages as well. Since you are probably serving this
          from a database, the database hit counter is probably the easiest to
          implement. If you add a timestamp and insert each entry you can fake
          your own easy to read server logs. Parsing the real server logs can be a
          tough task for a relative newbie.
          >
          Google "PHP Hit Counter".
          >
          Jeff
          >>
          >
          You can, but you have to ensure you lock the file before opening it, and
          unlock it after you close the file, to prevent multiple accesses (and
          possible file corruption).

          Databases are nice because they handle all of this for you.

          --
          =============== ===
          Remove the "x" from my email address
          Jerry Stuckle
          JDS Computer Training Corp.
          jstucklex@attgl obal.net
          =============== ===

          Comment

          • Jeff

            #6
            Re: Most Viewed PHP Tutorial

            Jerry Stuckle wrote:
            Jeff wrote:
            >Jerry Stuckle wrote:
            >>Alec wrote:
            >>>I am starting the creation of a simple news website in PHP, and would
            >>>like to include a section for the 'most viewed' or 'most popular'
            >>>articles.
            >>>>
            >>>As a beginner to PHP, I have looked on google for such tutorials but
            >>>to no avail.
            >>>>
            >>>Does anyone here know of one?
            >>>>
            >>>Many thanks,
            >>>>
            >>>Alec
            >>>>
            >>>
            >>You can either control the downloads yourself and increment a
            >>database counter when a particular article, or you can parse your web
            >>server logs to find out how many times a page has been accessed.
            >>Either works fine.
            >>
            > Just to add a bit to Jerry's remarks...
            >>
            > There's probably dozens of ways to do this. Although it is so easy
            >and ubiquitous to use a database, you can also just open a file and
            >either increment it or append a new line. The old hit counter trick
            >was to use a fake 1 pixel image:
            >>
            ><img src="path_to_hi t_counter_scrip t" height="1" width="1" alt="" />
            >>
            >That works for static pages as well. Since you are probably serving
            >this from a database, the database hit counter is probably the easiest
            >to implement. If you add a timestamp and insert each entry you can
            >fake your own easy to read server logs. Parsing the real server logs
            >can be a tough task for a relative newbie.
            >>
            > Google "PHP Hit Counter".
            >>
            > Jeff
            >>>
            >>
            >
            You can, but you have to ensure you lock the file before opening it, and
            unlock it after you close the file, to prevent multiple accesses (and
            possible file corruption).
            I was going to ask about that but I notice that php has flock. (Nice
            that it has the same syntax) I suppose that doesn't work on windows.
            >
            Databases are nice because they handle all of this for you.
            Agreed there!

            Jeff
            >

            Comment

            Working...