|
|
|
|
![]() ![]() |
![]() Group: Members
Posts: 17 Joined: 16-September 04 Member No.: 1,132 |
Post
#1
Sep 21 2004, 07:32 PM
I want a PHP code to display the most popular clicks/links on certain pages. Can anyone help? |
![]() Group: Members
Posts: 9 Joined: 8-October 04 Member No.: 1,524 |
Post
#2
Oct 8 2004, 07:16 PM
you need to create a counter database for each url in your site increment each time (using php) then create the stats |
![]() Group: Members
Posts: 10 Joined: 10-October 04 Member No.: 1,618 |
Post
#3
Oct 10 2004, 08:08 AM
virrey is right on. Think about added code to the top of each of the pages you wish to track. The query could insert $PHP_SELF into a page column, giving you a row for each page load. Alternately you could set up another field as "hits" and then do a query to see if a row for that page is already in the database. If it is, use UPDATE, if not, INSERT. Eventually when MySQL 4.1 goes from Gamma release to General, you will be able to use "INSERT... ON DUPLICATE KEY SET..." which will let the database decide whether to update or insert. |
![]() ![]() Group: Members
Posts: 32 Joined: 30-January 05 Member No.: 3,494 |
Post
#4
Feb 1 2005, 06:11 AM
You need a counter to track the clicks. There are 3 ways to do this. One is shared memory. Reference http://ca.php.net/manual/en/function.shm-attach.php One is files. You track the count in your file. Be care of the synchronize problem. the process should be: <? fopen() flock(LOCK_EX) fread() count++ fwrite() flock(LOCK_UN) fclose() ?> One is database. You save the click to database. QUOTE(XtremeGamer99 @ Sep 21 2004, 02:32 PM) I want a PHP code to display the most popular clicks/links on certain pages.
Can anyone help? [right][snapback]13863[/snapback][/right] |
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Group: Members
Posts: 217 Joined: 2-January 05 Member No.: 3,084 |
Post
#5
Feb 2 2005, 10:21 PM
QUOTE you need to create a counter database for each url in your site increment each time (using php) then create the stats or, in the full code, it will be just like this: create an database table whit the following rows: -id -name -clicks and an page called link.php: CODE <? mysql_connect("localhost","user","password"); mysql_select_db("databasename"); if(!$ref) // if area hadn't be specified die("You didn't specified an area!"); $ref = stripslashes($ref); // security reason mysql_query("UPDATE table SET clicks=(clicks+1) WHERE name='$ref';"); include("$ref.htm"); // include the real page ?> Now, you just need to fill the database with your areas and change all links. If the link was games.htm, it will be link.php?ref=games That's all :] if the script doesn't run, post again and I'll fix the problems. |
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Group: Members
Posts: 217 Joined: 2-January 05 Member No.: 3,084 |
Post
#6
Feb 2 2005, 10:31 PM
i've forgot... just completing. to display the most popular in tables, just write this code: show.php CODE <? // don't forget to connect with database ?> <table border="0"> <tr> <td>Area</td> <td>Clicks</td> </tr> <? $query = mysql_query("SELECT * FROM table ODER BY clicks LIMIT 5;"); // if you want to show 10 most popular, change 5 for 10, or if you want the 15 more, change for 15... blah blah blah while($most = mysql_fetch_array($query)){ ?> <tr> <td><?=$most[name]?></td> <td><?=$most[clicks]?></td> </tr> <? } ?> </table> that's all! You know, if this script doesn't run, post here and I'll fix it. And don't forget to conect whit the database in the top of this page. If u don't know how, just look at my other post. There is an example. I hope I've helped you! \_ |
![]() ![]() ![]() ![]() Group: Members
Posts: 74 Joined: 9-December 04 From: wales (bridgend) Member No.: 2,631 |
|
![]() ![]() |
Similar Topics
| Topic Title | Replies | Topic Starter | Views | Last Action | |||
|---|---|---|---|---|---|---|---|
![]() |
3 | -Sky- | 664 | 12th June 2009 - 08:48 PM Last post by: -Sky- |
|||
![]() |
7 | odomike | 19,029 | 30th April 2008 - 02:44 PM Last post by: FeedBacker |
|||
![]() |
97 | Xenon | 47,384 | 29th October 2009 - 04:25 PM Last post by: magiccode9 |
|||
![]() |
11 | bttfpromo | 11,547 | 14th September 2004 - 08:55 PM Last post by: Magic-Node |
|||
![]() |
25 | gijoe18 | 24,501 | 20th February 2009 - 06:55 PM Last post by: MALISH_ |
|||
![]() |
1 | BCD | 180 | 3rd September 2009 - 09:28 PM Last post by: truefusion |
|||
![]() |
5 | Tetraca | 1,252 | 15th July 2006 - 11:06 PM Last post by: Plenoptic |
|||
![]() |
4 | icss21 | 3,027 | 7th March 2009 - 09:45 PM Last post by: andreip |
|||
![]() |
3 | jglw22 | 891 | 26th May 2008 - 02:10 PM Last post by: Framp |
|||
![]() |
18 | FirefoxRocks | 2,106 | 2nd January 2009 - 08:07 AM Last post by: triplebtalk |
|||
![]() |
4 | Forbidden | 7,570 | 28th March 2008 - 07:37 PM Last post by: saran |
|||
![]() |
6 | sargilla | 6,812 | 4th November 2004 - 02:54 PM Last post by: Lyon |
|||
![]() |
4 | icss21 | 950 | 22nd July 2006 - 02:24 PM Last post by: JField |
|||
![]() |
0 | Lyon | 3,575 | 3rd November 2004 - 07:27 PM Last post by: Lyon |
|||
![]() |
0 | Dodger | 3,267 | 3rd November 2004 - 08:34 PM Last post by: Dodger |
|||
|
Open Discussion | Time is now: 22nd November 2009 - 10:03 AM |
Web Hosting Powered by ComputingHost.com.