Call a custom module's function from template file In the same context that this question, I want to add a link to a function in my custom module from a template file.

Something like this:

In my template file: &lt;a href="mymodule_my_function()" id="20"&gt;Action&lt;/a&gt;

In my custom module 

function my_function($id){ 
//update data base 
}
a function doesn't have a url unless you set up a callback url for it first with hook_menu. Then you can point your link to it and process the data. So in your case it'd look something roughly like that:

In your custom module:

function mymodule_menu() {
  $items['some_url/%'] = array(
    'page callback' =&gt; 'mymodule_myfunction',
    'page arguments' =&gt; array(
      1,
    ),
  );
  return $items;
}

function mymodule_myfunction($id) {
 // update database
}


Then in your template use l() as Kevin mentioned (you should adjust to fit your variables etc):

print l('Action', 'abc/20');


This is very simplified. You'd want to probably enable some access limitations on that new url (abc/%) etc and you can read more about that in the hook_menu docs I linked to above.