Viral Bhoot
Viral Bhoot

Reputation: 357

Call a function with parameter in codeigniter using hyperlink

I am using codeigniter. I want to call controller function with parameter from hyperlink in view page.

Here is code of View:

<a href="<?php site_url("report_attendance/export_leave_data/".$result['leavetype_id'])?>" name="leavereport" class="btn btn-sm btn-dark pull-right" style="width: 100px;margin-bottom: 10px;">Export</a>

Controller's function:

function export_leave_data($leaveid) 
{

}

Here, when I saw in inspect element, it shows nothing in href. Like this,

<a style="width: 100px;margin-bottom: 10px;" class="btn btn-sm btn-dark pull-right" name="leavereport" href="">Export</a>

So, actually where I am going wrong??

Upvotes: 1

Views: 971

Answers (1)

Ricky
Ricky

Reputation: 568

You are missing echo replace

<a href="<?php site_url("report_attendance/export_present_data/".$result['leavetype_id'])?>" name="leavereport" class="btn btn-sm btn-dark pull-right" style="width: 100px;margin-bottom: 10px;">Export</a>

to

<a href="<?php echo site_url("report_attendance/export_present_data/".$result['leavetype_id'])?>" name="leavereport" class="btn btn-sm btn-dark pull-right" style="width: 100px;margin-bottom: 10px;">Export</a>

Upvotes: 4

Related Questions