You are here: Re: URL description « PHP Programming Language « IT news, forums, messages
Re: URL description

Posted by Justin Koivisto on 01/09/06 17:41

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 - justin@koivi.com
http://koivi.com

 

Navigation:

[Reply to this message]


Удаленная работа для программистов  •  Как заработать на Google AdSense  •  England, UK  •  статьи на английском  •  PHP MySQL CMS Apache Oscommerce  •  Online Business Knowledge Base  •  DVD MP3 AVI MP4 players codecs conversion help
Home  •  Search  •  Site Map  •  Set as Homepage  •  Add to Favourites

Copyright © 2005-2006 Powered by Custom PHP Programming

Сайт изготовлен в Студии Валентина Петручека
изготовление и поддержка веб-сайтов, разработка программного обеспечения, поисковая оптимизация