Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 3 of 3
  1. #1
    New Coder
    Join Date
    Sep 2004
    Posts
    28
    Thanks
    1
    Thanked 0 Times in 0 Posts

    JavaScript and MySQL

    I am developing a website what contains links. I want to record down the hit rate of each link by MySQL database. Is it possible to use JavaScript to update the database when user click on the links?

  • #2
    New Coder
    Join Date
    Jan 2006
    Location
    Oslo, Norway
    Posts
    86
    Thanks
    0
    Thanked 0 Times in 0 Posts
    I don't think you can update the database directly from a javascript when you use it client side, as you do. However, you could use what is called Ajax-technology to acomplish this. Then you need a server side script that performs the database update.

    Perhaps it would be more easy to use redirecting or something like this:
    The link that is supposed to be open is http://www.hiof.no
    <a href="link.php?link=http://www.hiof.no">Click here</a>

    The link.php file could be something like this:
    PHP Code:
    // Get the link
    $link $_GET["link"];

    // Do the database updating
    // code here ...

    // Go to the requested link
    header("Location: {$link}"); 
    Drømmejenta: Kristen jente som progger Python!

  • #3
    New Coder
    Join Date
    Sep 2004
    Posts
    28
    Thanks
    1
    Thanked 0 Times in 0 Posts
    thanks


  •  

    Posting Permissions

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