#1
  1. No Profile Picture
    Junior Member
    Devshed Newbie (0 - 499 posts)

    Join Date
    Apr 2000
    Posts
    14
    Rep Power
    0
    Hi,

    All I wanna do is increment a variable $hits
    after a user has clicked on a HTML-link.

    How do I do that?
    Should I use the JavaScript "onClick" for that and put a value in $hits?

    Can anyone help me with this?

    Thanks in advance,
    DjMouse
  2. #2
  3. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Dec 1999
    Location
    Netherlands
    Posts
    77
    Rep Power
    15
    <BLOCKQUOTE><font size="1" face="Verdana,Arial,Helvetica">quote:</font><HR>Originally posted by djmouse:
    Hi,

    All I wanna do is increment a variable $hits
    after a user has clicked on a HTML-link.

    How do I do that?
    Should I use the JavaScript "onClick" for that and put a value in $hits?

    Can anyone help me with this?

    Thanks in advance,
    DjMouse
    [/quote]

    It depends on what you want to use the variable for and its scope.
    Do you want to permanently store the hits-value, use it in other documents/applications, or only for the time-being in this document?

    Then you can look at whether to use a solution in javascript, php or maybe store it in a database.

    Peter
  4. #3
  5. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Dec 1999
    Location
    Ann Arbor, MI USA
    Posts
    6
    Rep Power
    0
    As PAV said, it depends on what you want to do with the data, but since you're posting this in the PHP forum, I'll assume you're wanting to do something in PHP with it. Here's a pointer: check out the Header() function, and specifically the Location: header. You can have your link pointing to a PHP script which records the click, then re-directs to the destination.
  6. #4
  7. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Apr 2000
    Posts
    63
    Rep Power
    15
    Assuming that you're counting hits to a page...

    You can make a flat file with fopen and store the variable in there. Each time the link is hit, read the variable out of the file, increment it, and save it back in.

Similar Threads

  1. Help with Java Script
    By AShain in forum HTML Programming
    Replies: 1
    Last Post: February 17th, 2004, 05:29 AM
  2. PHP + MySQL query to make a link
    By emp/ir:kal in forum PHP Development
    Replies: 6
    Last Post: January 22nd, 2004, 01:10 PM
  3. If no next selected name link "link"
    By vacuity in forum PHP Development
    Replies: 1
    Last Post: January 7th, 2004, 02:42 AM
  4. JavaScript: If no text selected name link "link"
    By vacuity in forum JavaScript Development
    Replies: 0
    Last Post: January 6th, 2004, 10:35 PM
  5. chaning link color using css
    By titi in forum CSS Help
    Replies: 0
    Last Post: December 12th, 2003, 06:36 PM

IMN logo majestic logo threadwatch logo seochat tools logo