NYCPHP Meetup

NYPHP.org

[nycphp-talk] javascript calling php function -- now question on Ajax

Susan Shemin susan_shemin at yahoo.com
Mon Feb 18 23:58:23 EST 2008


thanks, Mike and Ken

first off, I'm not using a form (so no POST); the link is in an anchor tag.  I could put a form around it, but that seems to me making a simple link complex.

I want to run this php code when the link is clicked 

 $webpage="";
 $link_clicked="";

Function capture_click($webpage,$link_clicked)
{

     $entry_date=date("m-d-y-H-i");

      $sql = "INSERT INTO click_details " .
             "SET webpage='$webpage', link_clicked='$link_clicked', entry_date='$entry_date'";
      $ok = mysql_query($sql);

      if ($ok) {
        //error checking
      }
}
?>

and then the anchor text (or how I guessed would work)

<a href=www.nyphp.org onclick="<?php capture_click(name_of_my_webpage,link_name); ?>";>info on PHP</a>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.nyphp.org/pipermail/talk/attachments/20080218/b5f0cb3e/attachment.html>


More information about the talk mailing list