RipCurl
|
| Posted: 04/01/2003, 12:18 PM |
|
Using the links example provided, how can i go about adding count on how many times the link was visited?
Using CC 2.0.5 php + templates. Please, nothing with java/javascrip involved.
|
|
|
 |
Rip
|
| Posted: 06/10/2003, 2:50 PM |
|
??????
|
|
|
 |
Greed Master
|
| Posted: 06/11/2003, 2:34 AM |
|
You need some manual coding for this
I can give you some hints
1. Change your links example so your links go to some custom php page with link_id parameter in it:
count_clicks.php?link_id=1
count_clicks.php?link_id=2
...
2. Create new table to count links statistic
create table links_statistic
(
link_id int(11) not null,
clicks int(11)
);
3. Add custom code to your custom page count_clicks.php
$link_id = get_param("link_id");
$db->query("SELECT url FROM links WHERE link_id=" . $link_id);
if($db->next_record()) { // link exists we can proceed
$url = $db->f("url");
$db->query("SELECT link_id FROM links_statistic WHERE link_id=" . $link_id);
if($db->next_record()) { // increment field clicks by one
$db->query("UPDATE links_statistic SET clicks=clicks+1 WHERE link_id=" . $link_id);
} else { // add new record
$db->query("INSERT INTO links_statistic VALUES ($link_id, 1)");
}
// redirect to URL
header("Location: $url");
exit;
} else {
die("Wrong link_id parameter");
}
|
|
|
 |
RipCurl
|
| Posted: 06/11/2003, 12:46 PM |
|
Where do i do this?
1. Change your links example so your links go to some custom php page with link_id parameter in it:
count_clicks.php?link_id=1
count_clicks.php?link_id=2
...
Its a Grid, and the "url" field is the "name" of the link.
I can't specify coun_clicks.php for the linking page. Where do i assing this?
|
|
|
 |
RipCurl
|
| Posted: 06/11/2003, 12:54 PM |
|
oops. just made a new page, and inserted the code in the OPEN event of rthe page.
Now, How can i go about including the count for each link on the site next to their corresponding links?
|
|
|
 |
RipCurl
|
| Posted: 06/11/2003, 12:58 PM |
|
Nevermnd. I hate when i jump the gun like that. Just added the clicks ot the original link table and voila...
|
|
|
 |
RipCurl
|
| Posted: 06/11/2003, 1:57 PM |
|
Thanks a lot for the help.
I just realized that this could be modified easily to do a download type script to count and so that people can't leech it.
If i work it out, I'll post what I came up with.
|
|
|
 |