-3

Im searching a code split. I want to a link first click run a MySQL query and change link.

I found it this, but is only change text:

<script type="text/javascript"> 
$(document).ready(function() {  
    // hides the slickbox as soon as the DOM is ready  
    // (a little sooner than page load)   
    $('#slickbox').hide();

    // toggles the slickbox on clicking the noted link    
    $('a#slickbox-toggle').click(function() {
        $('#slickbox').slideToggle(400);
        return false;   
    }); 
}); 
</script> 
$(this).text($(this).text() == 'Show box' ? 'Hide box' : 'Show box');

Example: Facebook like button =>

Like (56 likes)
Click (update likes ...... ..... likecount+=1) Unlike (57 likes)

How can i do this?

pmr
  • 58,701
  • 10
  • 113
  • 156
Sirchade
  • 35
  • 1
  • 6

1 Answers1

0

You have to execute an AJAX request in your onclick handler. This will need to interact with some sort of webservice or script that makes the SQL query.

The norm is to use AJAX to send a request to a PHP script that uses the MySQL API to interact with a MySQL database.

Googling any of those keywords will give you many examples and tutorials that you can follow.

Jivings
  • 22,834
  • 6
  • 60
  • 101