Re: [PHP] counting hyperlink clicks in php

2007-02-20 Thread Richard Lynch
On Sat, February 17, 2007 1:53 pm, clive wrote:
> Denis L. Menezes wrote:
>> Dear friends.
>>
>> I have a site where I have news headers. I wish to count the clicks
>> on the
>> news headers so that I can see how many times each of the the news
>> has been
>> viewed. This way I can show the "most viewed" news.
>>
>> Can one of you please advise hwo this can be done?
>>
>>
> add to each news item like &clicked=1 and in the page where you
> display
> the news item, checked if clicked exists, if does write it to a file
> or
> a db (obviously with the news item id), if your using mysql, the heap
> table type is quite useful, you will however need to move the info to
> a
> more permanent table every x amount of clicks.

Do you really only want to count the clicks from your own page?

Or, put another way, if somebody posts an external link on slashdot
and a news story is getting a zillion views from that, do you want to
count those as well?

It would seem to me that in your "view" script that displays the story
you could simply do something like:

update story set views = views + 1 where story_id = $story_id

And not even worry about the mucking with AJAX nor tracking it from
only your own page.

-- 
Some people have a "gift" link here.
Know what I want?
I want you to buy a CD from some starving artist.
http://cdbaby.com/browse/from/lynch
Yeah, I get a buck. So?

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] counting hyperlink clicks in php

2007-02-20 Thread Fergus Gibson
Brad Bonkoski wrote:
> I think the best way to do this would be to set an onClick (Javascript)
> event handler for each of the links, and then use AJAX style stuff to
> send the information to PHP on the server side, then PHP can log the
> link that was clicked, and keep track of the most clicked links.

The only problem with this suggestion is the dependency on Javascript.
This would not count clicks from browsers that don't support JS or from
users who have disabled it in their browsers.

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] counting hyperlink clicks in php

2007-02-17 Thread clive

Denis L. Menezes wrote:

Dear friends.

I have a site where I have news headers. I wish to count the clicks on the 
news headers so that I can see how many times each of the the news has been 
viewed. This way I can show the "most viewed" news.


Can one of you please advise hwo this can be done?

  
add to each news item like &clicked=1 and in the page where you display 
the news item, checked if clicked exists, if does write it to a file or 
a db (obviously with the news item id), if your using mysql, the heap 
table type is quite useful, you will however need to move the info to a 
more permanent table every x amount of clicks.


clive

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re[2]: [PHP] counting hyperlink clicks in php

2007-02-17 Thread Ed Grigoryan
Hello Brad,

Saturday, February 17, 2007, 4:22:22 PM, you wrote:

> Denis L. Menezes wrote:
>> Dear friends.
>>
>> I have a site where I have news headers. I wish to count the clicks on the
>> news headers so that I can see how many times each of the the news has been
>> viewed. This way I can show the "most viewed" news.
>>
>> Can one of you please advise hwo this can be done?
>>
>> Thanks
>> Denis 
>>
>>   
> I think the best way to do this would be to set an onClick (Javascript)
> event handler for each of the links, and then use AJAX style stuff to
> send the information to PHP on the server side, then PHP can log the
> link that was clicked, and keep track of the most clicked links.
> -B


Another way to do this is to take the user to a page that would
identify the clicked link (by ID, for example), store the visits data
to a database or a text file and then redirect to the corresponding
news. So, such link might look like this:
http://www.news.com/redirect.php?news_id=150";>read news

Hope this helps.

Ed

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] counting hyperlink clicks in php

2007-02-17 Thread Brad Bonkoski

Denis L. Menezes wrote:

Dear friends.

I have a site where I have news headers. I wish to count the clicks on the 
news headers so that I can see how many times each of the the news has been 
viewed. This way I can show the "most viewed" news.


Can one of you please advise hwo this can be done?

Thanks
Denis 

  
I think the best way to do this would be to set an onClick (Javascript) 
event handler for each of the links, and then use AJAX style stuff to 
send the information to PHP on the server side, then PHP can log the 
link that was clicked, and keep track of the most clicked links.

-B

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



[PHP] counting hyperlink clicks in php

2007-02-17 Thread Denis L. Menezes
Dear friends.

I have a site where I have news headers. I wish to count the clicks on the 
news headers so that I can see how many times each of the the news has been 
viewed. This way I can show the "most viewed" news.

Can one of you please advise hwo this can be done?

Thanks
Denis 

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php