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>


avatar cahbond
@cahbond

33 Kontribusi 3 Poin

Diperbarui 6 tahun yang lalu

2 Jawaban:

sepertinya kurang slash gan <pre> &lt;td&gt;&lt;img src="../img/&lt;?php echo $row-&gt;gambar; ?&gt;" &gt;&lt;/td&gt; </pre>

avatar dianarifr
@dianarifr

642 Kontribusi 316 Poin

Dipost 6 tahun yang lalu

masih belom gan.. ini script phpnya gan?

<pre>

&lt;?php

class Upload extends CI_Controller{ function __construct(){ parent::__construct(); $this-&gt;load-&gt;model('m_upload'); $this-&gt;load-&gt;library('upload'); }

function index(){
    $this-&amp;gt;load-&amp;gt;view(&#039;v_upload&#039;);
}

function upload_image(){
    $config[&#039;upload_path&#039;] = &#039;./img/&#039;; //path folder
    $config[&#039;allowed_types&#039;] = &#039;gif|jpg|png|jpeg|bmp&#039;; //type yang dapat diakses bisa anda sesuaikan
    $config[&#039;encrypt_name&#039;] = TRUE; //Enkripsi nama yang terupload

    $this-&amp;gt;upload-&amp;gt;initialize($config);
    if(!empty($_FILES[&#039;filefoto&#039;][&#039;name&#039;])){

        if ($this-&amp;gt;upload-&amp;gt;do_upload(&#039;filefoto&#039;)){
            $gbr = $this-&amp;gt;upload-&amp;gt;data();
            //Compress Image
            $config[&#039;image_library&#039;]=&#039;gd2&#039;;
            $config[&#039;source_image&#039;]=&#039;./img/&#039;.$gbr[&#039;file_name&#039;];
            $config[&#039;create_thumb&#039;]= FALSE;
            $config[&#039;maintain_ratio&#039;]= FALSE;
            $config[&#039;quality&#039;]= &#039;50%&#039;;
            $config[&#039;width&#039;]= 600;
            $config[&#039;height&#039;]= 400;
            $config[&#039;new_image&#039;]= &#039;./img/&#039;.$gbr[&#039;file_name&#039;];
            $this-&amp;gt;load-&amp;gt;library(&#039;image_lib&#039;, $config);
            $this-&amp;gt;image_lib-&amp;gt;resize();

            $gambar=$gbr[&#039;file_name&#039;];
            $judul=$this-&amp;gt;input-&amp;gt;post(&#039;xjudul&#039;);
            $this-&amp;gt;m_upload-&amp;gt;simpan_upload($judul,$gambar);
            $data[&#039;query_no&#039;] =$this-&amp;gt;db-&amp;gt;get(&#039;tbl_galeri&#039;);
            $this-&amp;gt;load-&amp;gt;view(&#039;view_sukses&#039;,$data);
        }
                  
    }else{
        echo &quot;Image yang diupload kosong&quot;;
    }
             
}

}

?&gt; </pre>

avatar cahbond
@cahbond

33 Kontribusi 3 Poin

Dipost 6 tahun yang lalu

Login untuk ikut Jawaban