I am using DataTables to generate a table. There is a column containing username
For example: ...
I need every row in this column to have a hyperlink when anyone clicks on username then it redirects to edit page, For example, the first row would be a hyperlink to view?id=1321755 etc.
What is the simplest way I can do so?
Here is my code of view:
<table id="book-table" class="table table-bordered table-striped table-hover">
<thead>
<tr class="">
<th>Name</th>
<th>Date</th>
<th>Work</th>
<th>Partner</th>
<th>Director</th>
<th>Time</th>
<th>Task</th>
<th>Status</th>
</tr>
</thead>
<tbody>
</tbody>
</table>
<script type="text/javascript">
$(document).ready(function() {
$('#book-table').DataTable({
"ajax": {
url : "<?php echo site_url("digital_admin/hodm/books_page") ?>",
type : 'GET'
},
});
});
</script>
Here is my controller code:
public function books_page()
{
// Datatables Variables
$draw = intval($this->input->get("draw"));
$start = intval($this->input->get("start"));
$length = intval($this->input->get("length"));
$books = $this->pojo->get_books();
$data = array();
foreach($books->result() as $r) {
$data[] = array(
$r->user_name,
$r->date,
$r->t_name,
$r->partner,
$r->director,
$r->duration,
$r->task,
$r->status
);
}
$output = array(
"draw" => $draw,
"recordsTotal" => $books->num_rows(),
"recordsFiltered" => $books->num_rows(),
"data" => $data
);
echo json_encode($output);
exit();
}
Kindly help me to find the answer
'<a href="view?id='. $r->user_id .'" >'. $r->user_name .'</a>';