zek2005 wrote:
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??
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_escape_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 -
ju****@koivi.com http://koivi.com