Code:
<td class="text-center">
<button class="btn btn-sm btn-danger deleteUser" data-toggle="modal"
data-target="#myModal1" onclick="edit_book1(<?php echo $row['markid'];?>)">
<i class="fa fa-upload"></i></button>
</td>
Code:
function edit_book1(markid)
{
save_method = 'update';
$('#form1')[0].reset(); // reset form on modals
//Ajax Load data from ajax
$.ajax({
url : "<?php echo site_url('/users/ajax_edit1')?>/" + markid,
type: "POST",
dataType: "JSON",
success: function(data)
{
console.log(data);
alert(data);
//window.alert($('[name=title]').val(data.markid));
$('[name="markid1"]').val(data.file_name);
// $('[name="appno"]').val(data.appno);
$('#modal_form1').modal('show'); // show bootstrap modal when complete loaded
$('.modal-title').text('Upload Images'); // Set title to Bootstrap modal title
},
error: function (jqXHR, textStatus, errorThrown)
{
alert('Error get data from ajax');
}
});
}
Code:
Controller
**********
public function ajax_edit1($markid)
{
$data = $this->User_Model->getRows($markid);
echo json_encode($data);
}
Code:
Model
*****
function getRows($markid = array()){
$this->db->select('*');
$this->db->from('upload_ins');
$this->db->where('certid',$markid);
$query = $this->db->get();
return $query->row();
}
Code:
Model window
************
<?php if(!empty($files)){ foreach($files as $frow)
{
print_r($frow);
?>
<embed src = "<?php echo base_url().'uploads/files/'.$frow ['file_name']; ?>" type='application/pdf' frameborder="0" width="100%" height="400px">