Я проектирую регистр активов и пытаюсь загрузить несколько изображений в ID как можно дальше, чтобы легче идентифицировать актив, но я изо всех сил пытаюсь отобразить одно маленькое изображение в моей таблице данных и несколько изображений на странице просмотра.
Я пытался с циклом foreach и пытался выводить файлы из моей базы данных, но каждый раз, когда я получал небольшие серые изображения в моих представлениях и таблицах
Контроллер
$data = array(
'formTitle' => 'Create Asset',
'title' => 'Create Asset',
);
$this->load->library('form_validation');
$this->form_validation->set_rules('asset_name', 'Asset Name', 'trim|required|callback_select_validate');
$this->form_validation->set_rules('asset_description', 'Asset Description', 'trim|required|callback_category_validate');
$postData = $this->input->post();
if($this->form_validation->run() === FALSE)
{
$data['supplier'] = $this->admin_model->get_supplier();
$data['asset_category'] = $this->admin_model->get_asset_category();
$data['location'] = $this->admin_model->get_location();
$data['room'] = $this->admin_model->get_room();
$data['status'] = $this->admin_model->get_status();
$this->load->view('frame/header_view');
$this->load->view('frame/sidebar_nav_view');
$this->load->view('asset/create_asset', $data);
}
else
{
$name_array = array();
$count = count($_FILES['userfile']['size']);
foreach($_FILES as $key=>$value)
for($s=0; $s<=$count-1; $s++) {
$_FILES['userfile']['name']=$value['name'][$s];
$_FILES['userfile']['type'] = $value['type'][$s];
$_FILES['userfile']['tmp_name'] = $value['tmp_name'][$s];
$_FILES['userfile']['error'] = $value['error'][$s];
$_FILES['userfile']['size'] = $value['size'][$s];
$config['upload_path'] = './uploads/asset';
$config['allowed_types'] = 'gif|jpg|png';
$this->load->library('upload', $config);
$this->upload->do_upload();
$data = $this->upload->data();
$name_array[] = $data['file_name'];
}
$names= implode(',', $name_array);
//Prepare array of user data
$userData = array(
'name' => $this->input->post('asset_name'),
'item_description' => $this->input->post('asset_description'),
'brand' => $this->input->post('brand'),
'serial_number' => $this->input->post('asset_serial'),
'model' => $this->input->post('asset_model'),
'supplier' => $this->input->post('supplier'),
'category' => $this->input->post('asset_category'),
'location' => $this->input->post('location'),
'room' => $this->input->post('room'),
'date_pruchase' => $this->input->post('date_purchase'),
'purchase_price' => $this->input->post('purchase_price'),
'ip' => $this->input->post('ip'),
'mac' => $this->input->post('mac'),
'status' => $this->input->post('status'),
'files' => $names
);
//Pass user data to model
$insertUserData = $this->admin_model->inset_asset($userData);
//Storing insertion status message.
if($insertUserData){
$this->session->set_flashdata('success_msg', 'User data have been added successfully.');
print_r($userData);
}else{
$this->session->set_flashdata('error_msg', 'Some problems occured, please try again.');
}
redirect('admin/create_asset');
}
}
}
Модель
function inset_asset($data = array())
{
if(!array_key_exists("created",$data)){
$data['created'] = date("Y-m-d H:i:s");
}
$insert = $this->db->insert('tbl_asset_register', $data);
if($insert){
return $this->db->insert_id();
}else{
return false;
}
}
Моя таблица / представление представления актива.
function asset_list(){
$data = array(
'formTitle' => 'Open Calls',
'title' => 'Open Calls',
'asset' => $this->admin_model->get_asset_list(),
);
$this->load->view('frame/header_view');
$this->load->view('frame/sidebar_nav_view');
$this->load->view('asset/view_asset', $data);
}
function show_asset($id)
{
$data = array(
'formTitle' => 'View Asset',
'title' => 'Asset Management'
);
$data["data"] = $this->admin_model->get_assets('', '', $id);
$this->load->view('frame/header_view');
$this->load->view('frame/sidebar_nav_view');
$this->load->view('asset/shows_asset', $data);
}
таблица данных
<div class="row">
<div class="col-lg-12">
<table class="table table-striped table-bordered table-hover" id="dtBasicExample">
<thead>
<tr>
<th>Asset ID:</th>
<th>Name:</th>
<th>Location:</th>
<th>Room:</th>
<th>Serial No.:</th>
<th>View Images:</th>
<th><strong>Option</strong></th>
</tr>
</thead>
<tbody>
<?php foreach($asset as $row): ?>
<tr>
<td><?php echo $row->id; ?></td>
<td><?php echo $row->name; ?></td>
<td><?php echo $row->location; ?></td>
<td><?php echo $row->room; ?></td>
<td><?php echo $row->serial_number; ?></td>
<td><a href="<?php echo base_url('admin/show_asset/' . $row->id); ?>"><button type="button" class="btn btn-primary">view</button></a></td>
<td><a href="<?php echo base_url('admin/update_ob/' . $row->id); ?>"><button type="button" class="btn btn-primary">Edit</button></a></td>
</tr>
<?php endforeach; ?>
</tbody>
</table>
</div>
<!-- /.col-lg-12 -->
</div>
<!-- /.row -->
</div>
представление Страница
<div class="col-lg-12">
<ul class="gallery">
<?php if(!empty($files)){ foreach($files as $file){ ?>
<li class="item">
<img src="<?php echo base_url('uploads/asset/'.$file['files']); ?>" >
</li>
<?php } }else{ ?>
<p>Image(s) not found.....</p>
<?php } ?>
</ul>
</div>
Я смотрю на два способа просмотра таблицы.Одна кнопка для просмотра всех изображений или одно маленькое изображение в таблице.
На мой взгляд, я хочу просмотреть все изображения в нижней части своих страниц.