Results 1 to 20 of 20
  1. #1
    Join Date
    May 2010
    Posts
    86

    Question Need help!!!! with table

    Hi Guys/Gals,

    I have a table on a right hand side of my web page in which there are links. Is there a way or some code i can insert so as to measure how many hits or how many times the certain link have been used like to check on for monthly or weekly basis.
    here's the code of my table:
    <div style="width:223px; float:right; border:1px solid #CCCCCC; height: 350px;"><ul>
    <li style="height400px; font-weight: bold; background: url(images/title_right_text.jpg) no-repeat left top;padding:10px ;"></li>
    <li><a href="http://" target="_blank">A</a></li>
    <li><a href="http://" target="_blank">B</a></li>
    <li><a href="https://" target="_blank">C</a></li>
    <li><a href="http://" target="_blank">D</a></li>
    <li><a href="https://" target="_blank">E</a></li>

    </ul>
    </div>
    I am not inserting the links here as they are internal.

    I would really appreciate any help. Thanks in advance.
    Last edited by Harzem; 10-28-2012 at 10:19 AM. Reason: on request

  2. #2
    Join Date
    May 2011
    Location
    UT,US
    Posts
    204
    I think the best way you can do this is with a Google Analytics Account. It will monitor all your traffic for you as well as give you tips. Clearly your best bet.

    But, if you really want to code it, you can use this PHP script in all of the pages your table links to:

    Code:
    <?php
    $count_my_page = ("PGPhitcounter.txt");
    $hits = file($count_my_page);
    $hits[0] ++;
    $fp = fopen($count_my_page , "w");
    fputs($fp , "$hits[0]");
    fclose($fp);
    ?>
    You then make a text file in the root directory of your site called "PGPhitcounter.txt". This is obvoiusly for your PGP link, and you should make other files and alter the PHP script for your other pages.

    Then, you could make a page called, let's say, hitcounts.php. Design it how you like, but use this script to tell you how many hits that page has got:

    Code:
    <?php
    $filename= "PGPhitcounter.txt" ;
    $fd = fopen ($filename , "r") or die ("Can't open $filename") ;
    $fstring = fread ($fd , filesize ($filename)) ;
    echo "$fstring" ;
    fclose($fd) ;
    ?>
    If you used that code for all your linked pages (altering it for each page of course) you could have a web page that would keep a count of all those pages.

    All this being said, you really should go with Google Analytics. Hope this helped.

    P.S. I'm not manly enough to post URL links on this site quite yet, so Google "google analytics".

  3. #3
    Join Date
    May 2010
    Posts
    86
    @ T-Junk: first of all thank u very much. "google analytics" can't work on our hosting server as its kind of internal thing.

    the table is only on the main page. sorry but i am kind of new to all this. Sorry but where do i insert the PHP script.

  4. #4
    Join Date
    May 2011
    Location
    UT,US
    Posts
    204
    You put the first PHP script on the actual page that is linked. So, if your link in the table is PGP, on the actual page in the HEAD, you insert that script. Then, you make a web page just for you to view using the second script in the BODY content, like this:
    Code:
    <p>The number of hits on the PGP page is:</p>
    <p>
    <?php
    $filename= "PGPhitcounter.txt" ;
    $fd = fopen ($filename , "r") or die ("Can't open $filename") ;
    $fstring = fread ($fd , filesize ($filename)) ;
    echo "$fstring" ;
    fclose($fd) ;
    ?>
    </p>
    It shouldn't be to bad for 4 pages, but if your table is an example, and you have 20 pages, that could be a pain!

  5. #5
    Join Date
    May 2010
    Posts
    86
    Tnx, i am going to try that will let u know.
    sorry 1 more question. just wanna make sure, it will only tell me that how many ppl clicked on the link from that table.
    here's how my table looks like:
    http://i53.tinypic.com/24ow0gg.jpg

  6. #6
    Join Date
    May 2011
    Location
    UT,US
    Posts
    204
    The script will teel you how many hits the page gets, from the links or otherwise. But, usually people use sitelinks to navigate your site anyway, unless they bookmark a page. It should work. However, you know your site and the setting much better than I. Sorry if that doesn't work for you.

  7. #7
    Join Date
    May 2011
    Location
    UT,US
    Posts
    204
    Just an idea, but it seems like a lot of redundant work:

    Make your links go to a redirect page, then put the PHP counter script on the redirect page. That way, it counts hits to your redirect page, not to the actual page itself.

    There has to be an easier way of doing this, so hopefully another member has an idea. Otherwise, that should work.

    Sorry, I hope that works for you.

  8. #8
    Join Date
    May 2010
    Posts
    86
    My whole point to have this encounter is to know which link is popular and so i can replace the one which is not used more often. I hope i am not making you confused.

  9. #9
    Join Date
    May 2011
    Location
    UT,US
    Posts
    204
    My apologies, I am a little confused. This would technicaly do that (tell you what link is the most clicked), if you use a redirect page in between the link and the actual page.

    Here's the idea:

    A redirect page for , let's say, PGP.htm (This code NOT TESTED!)
    Code:
    <?php
    $count_my_page = ("PGPhitcounter.txt");
    $hits = file($count_my_page);
    $hits[0] ++;
    $fp = fopen($count_my_page , "w");
    fputs($fp , "$hits[0]");
    fclose($fp);
    /* Redirect browser */
    header("Location: PGP.htm");
    /* Make sure that code below does not get executed when we redirect. */
    exit;
    ?>
    Put that code in a page by itself and call it PGPredirect.php, then point your link to that. It SHOULD work.

    Like I said, I am pretty sure there is a simpler way to do this, so I hope somebody steps up with a better idea.

  10. #10
    Join Date
    May 2011
    Location
    California
    Posts
    6
    I agree...use Google Analytics.

  11. #11
    Join Date
    May 2011
    Location
    Fort Lauderdale, Florida
    Posts
    19
    You could simply check your server log files to see how many visits each page is getting.

  12. #12
    Join Date
    May 2010
    Posts
    86
    @sarasmile: can't use Google Analytics as it wont work bcoz of the internal hosting thing.
    @CuzinMikE: i need to to know how many times the link have been clicked from the table not that page.

  13. #13
    Join Date
    May 2011
    Location
    UT,US
    Posts
    204
    I think I found something that will work for you. Try this:

    Freeware Link Counter Script

    Hope this does it.
    This Geeks Blog Site | | Need moral support? Got it HERE!!!

  14. #14
    Join Date
    May 2010
    Posts
    86
    T-Junk: tnx a ton. i think this is what i was looking for. Sorry to be pain but could you plz advise if this wht i have to do:
    in the above table i insert the link like this
    wht i did now is for e.g:
    i copied the link_counter.php and link_counter.txt file to the main directory and the code i used is:
    Code:
    <li><a href="../IT/link_counter.php?url=http://userinfo/" target="_blank">User Info Tool</a></li>
    or this needs to be done on the link_counter.php page.

  15. #15
    Join Date
    May 2011
    Location
    UT,US
    Posts
    204
    It doesn't appear that you have to edit link_counter.php at all. Just edit your links right. That is to say:

    If in your root directory, you have link_counter.php in a folder called IT, your link should look like this:
    HTML Code:
    <li><a href="IT/link_counter.php?url=http://userinfo/" target="_blank">User Info Tool</a></li>
    I know that with the counter I posted previously, I had to edit the .txt file and give everything a value of "1" for it to work. Hope that is not the case here.

    (I KNEW there was an easier way to do this!!!!)
    This Geeks Blog Site | | Need moral support? Got it HERE!!!

  16. #16
    Join Date
    May 2010
    Posts
    86
    Tnx again, IT is the main folder where I have all the files of website. Also the website is not live yet. Tnx a lot once again.

  17. #17
    Join Date
    May 2010
    Posts
    86
    @T-Junk: unfortunately it did not work
    It just won't open the link.

  18. #18
    Join Date
    May 2011
    Location
    UT,US
    Posts
    204
    I knew it wouldn't be THAT easy!!!

    1. Does it register on the PHP page?
    2. If you take the extra "link_counter.php" path out, does the link work?

    You may have to reconfigure that link. When I get a chance, I will test it on my server and report back.
    This Geeks Blog Site | | Need moral support? Got it HERE!!!

  19. #19
    Join Date
    May 2011
    Location
    UT,US
    Posts
    204
    Okay, so I copied your table from the first post of this thread, made 5 little test pages for the links, and integrated the counter code into the links.

    It appears to me that everything is working fine. I am impressed with the admin counter page functionality.

    One thing I can think of is that the README file says:
    - All links have to have the "http://" before them for the script to
    properly redirect the user.
    I noticed that you were using a secure website in your links (https://), although I couldn't see that causing trouble.

    I would have to actually see the whole links to figure out the problem. If you want to PM me, I can send you a link of my working example.

    Sorry this has been such a pain for you.
    This Geeks Blog Site | | Need moral support? Got it HERE!!!

  20. #20
    Join Date
    May 2010
    Posts
    86
    Tnx. its working now. i removed the all bit before link.php in the path. I am also very impressed with the admin counter page functionality.

    THANKS a lot for your help T-junk

Similar Threads

  1. MySQL: Copy specific fields from Table A into Table B
    By damainman in forum Programming Discussion
    Replies: 4
    Last Post: 09-28-2010, 05:19 PM
  2. Sorting a table by the results of another table (MySQL/PHP)
    By jon31 in forum Programming Discussion
    Replies: 4
    Last Post: 07-10-2007, 07:51 PM
  3. Synchronize MSSQL Table (DB) with a MySQL Table (DB)
    By kalinga in forum Hosting Security and Technology
    Replies: 0
    Last Post: 03-26-2006, 12:58 AM
  4. Table help
    By Studio-10 in forum Web Design and Content
    Replies: 6
    Last Post: 03-28-2004, 04:05 AM
  5. Moving a row from table A to Table B?
    By ChickenSteak in forum Programming Discussion
    Replies: 3
    Last Post: 05-11-2003, 01:16 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •