在我的应用程序中,我上传图片并填写一些字段。这些值和上传图像路径也保存在数据库中。我不知道如何从文件夹中检索图像。我的代码是,
控制器部分是
function getdatatableajax()
{
$this->load->library('datatables');
$this->datatables
->select("products.id as id, pathinfo, products.name as pname, price, measurement, tax_rates.name")// measurement,tax_rates.name
->from("products")
->join('tax_rates', 'tax_rates.id=products.tax_rate', 'left')
->group_by('products.id')
->add_column("Actions",
"<center>
<div class='btn-group'>
<a class=\"tip btn btn-primary btn-xs\" title='".$this->lang->line("edit_product")."' href='index.php?module=products&view=edit&id=$1'>
<i class=\"fa fa-edit\"></i></a>
<a class=\"tip btn btn-danger btn-xs\" title='".$this->lang->line("delete_product")."' href='index.php?module=products&view=delete&id=$1' onClick=\"return confirm('". $this->lang->line('alert_x_product') ."')\">
<i class=\"fa fa-trash-o\"></i></a>
</div></center>", "id")
->unset_column('id');
echo $this->datatables->generate();
}
模型部分是
public function getAllProducts()
{
$q = $this->db->get('products');
if($q->num_rows() > 0) {
foreach (($q->result()) as $row) {
$data[] = $row;
}
return $data;
}
}
视图部分是
<table id="fileData" cellpadding=0 cellspacing=10 class="table table-bordered table-hover table-striped">
<thead>
<tr>
<th><?php echo $this->lang->line("Image"); ?></th>
<th><?php echo $this->lang->line("name"); ?></th>
<th><?php echo $this->lang->line("price"); ?></th>
<th><?php echo $this->lang->line("Measurement"); ?></th>
<th><?php echo $this->lang->line("tax_rate"); ?></th>
<th style="width:45px;"><?php echo $this->lang->line("actions"); ?></th>
</tr>
</thead>
<tbody>
<tr>
<td colspan="7" class="dataTables_empty"><?php echo $this->lang->line('loading_data_from_server'); ?></td>
</tr>
</tbody>
<tfoot>
<tr>
<th><?php echo $this->lang->line("Image"); ?></th>
<th><?php echo $this->lang->line("name"); ?></th>
<th><?php echo $this->lang->line("price"); ?></th>
<th><?php echo $this->lang->line("Measurement"); ?></th>
<th><?php echo $this->lang->line("tax_rate"); ?></th>
<th style="width:45px;"><?php echo $this->lang->line("actions"); ?></th>
</tr>
</tfoot>
</table>
从哪里添加图像检索代码。?
答案 0 :(得分:0)