Postingan lainnya
Buku Ini Koding!
Baru!
Buku ini akan jadi teman perjalanan kamu belajar sampai dapat kerjaan di dunia programming!
menampilkan gambar dari database
agan cara menampilkan image dari database itu bagaimana, saya coba cuma nampak kotak doang... minta solusinya
<table id="datatables" class="table table-bordered table-hover">
<tr>
<th>nomer</th>
<th>judul</th>
<th>gambar</th>
</tr>
<tbody>
<tr>
<?php
$no=0;
foreach($query_no->result() as $row){
?>
<td><?php echo $no++; ?></td>
<td><?php echo $row->judul; ?></td>
<td><img src="../img<?php echo $row->gambar; ?>" ></td>
</tr>
<?php }?>
</tbody>
</table>
2 Jawaban:
sepertinya kurang slash gan <pre> <td><img src="../img/<?php echo $row->gambar; ?>" ></td> </pre>
masih belom gan.. ini script phpnya gan?
<pre>
<?php
class Upload extends CI_Controller{ function __construct(){ parent::__construct(); $this->load->model('m_upload'); $this->load->library('upload'); }
function index(){
$this-&gt;load-&gt;view('v_upload');
}
function upload_image(){
$config['upload_path'] = './img/'; //path folder
$config['allowed_types'] = 'gif|jpg|png|jpeg|bmp'; //type yang dapat diakses bisa anda sesuaikan
$config['encrypt_name'] = TRUE; //Enkripsi nama yang terupload
$this-&gt;upload-&gt;initialize($config);
if(!empty($_FILES['filefoto']['name'])){
if ($this-&gt;upload-&gt;do_upload('filefoto')){
$gbr = $this-&gt;upload-&gt;data();
//Compress Image
$config['image_library']='gd2';
$config['source_image']='./img/'.$gbr['file_name'];
$config['create_thumb']= FALSE;
$config['maintain_ratio']= FALSE;
$config['quality']= '50%';
$config['width']= 600;
$config['height']= 400;
$config['new_image']= './img/'.$gbr['file_name'];
$this-&gt;load-&gt;library('image_lib', $config);
$this-&gt;image_lib-&gt;resize();
$gambar=$gbr['file_name'];
$judul=$this-&gt;input-&gt;post('xjudul');
$this-&gt;m_upload-&gt;simpan_upload($judul,$gambar);
$data['query_no'] =$this-&gt;db-&gt;get('tbl_galeri');
$this-&gt;load-&gt;view('view_sukses',$data);
}
}else{
echo "Image yang diupload kosong";
}
}
}
?> </pre>