URL description

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

    URL description

    I want to create a ranking of pages visited in my site. So, every time
    a page is accesed, I want to read the database and increased in + 1 the
    field "visited" to the specified URL.

    To do this, I need a variable with the URL. How do I give the variable
    that value??

    Thanks!

    Ezequiel

  • Justin Koivisto

    #2
    Re: URL description

    zek2005 wrote:[color=blue]
    > I want to create a ranking of pages visited in my site. So, every time
    > a page is accesed, I want to read the database and increased in + 1 the
    > field "visited" to the specified URL.
    >
    > To do this, I need a variable with the URL. How do I give the variable
    > that value??[/color]

    Why do you need a variable in the URL? Just knowing what the database
    key is should be all you need.

    If you using something like $_SERVER['REQUEST_URI'] as the primary key
    in the database, then all you need to do is something similar to:

    $query='UPDATE table SET count = count + 1 WHERE page =
    \'.mysql_real_e scape_string($_ SERVER['REQUEST_URI']).'\'';

    Then, if the query succeeds but affected rows == 0, you'll need to do an
    insert instead:

    $query='INSERT INTO table (page, count) VALUES
    (\'.mysql_real_ escape_string($ _SERVER['REQUEST_URI']).'\',1)';

    However, before doing this consider the effect that a search engine
    spider will have on the database... you may want to use some filtering
    of how/when the queries are executed...

    --
    Justin Koivisto, ZCE - justin@koivi.co m

    Comment

    Working...