Yii Framework Forum: Tampil Gambar Dari Database - Yii Framework Forum

Jump to content

Page 1 of 1
  • You cannot start a new topic
  • You cannot reply to this topic

Tampil Gambar Dari Database manggil path gambar yang ada di datebase Rate Topic: -----

#1 User is offline   _mifta 

  • Newbie
  • Yii
  • Group: Members
  • Posts: 6
  • Joined: 06-March 13
  • Location:Surabaya

Posted 08 March 2013 - 02:15 AM

Mau tanya dong mas,saya masih baru nih
Gimana cara manggil path dari database buat nampilin gambar yang udah diupload?

ini sedikit script saya:

widget(‘zii.widgets.grid.CGridView’, array(
‘id’=>’participant-grid’,
‘dataProvider’=>$toparticipant->search(),
//’filter’=>$totraining,
‘emptyText’=>’Belum ada training pada kategori ini’,
‘summaryText’=>”,
‘selectableRows’=>2,
‘columns’=>array(
array(
‘class’=>’CCheckBoxColumn’,
‘id’=>’haha’,
),
array(
‘name’=>’Name Participant’,
‘type’=>’raw’,
‘value’=>’Chtml::link($data->name_participant,array(\’participant/view\’,\’id\’=>$data->idparticipant))’,
),
array(
‘name’=>’Gambar’,
‘type’=>’raw’,
‘value’=>’CHtml::image(\’a/../images/$a.jpg\’, \’DORE\’, array(“width”=>50))’,
),
array(
‘class’=>’CButtonColumn’,
),

)
)); ?>
0

#2 User is offline   C.S.Putera 

  • Junior Member
  • Pip
  • Yii
  • Group: Members
  • Posts: 92
  • Joined: 18-May 11

Posted 08 March 2013 - 02:26 AM

Hello. Bisa seperti ini :

...
array(
     ‘name’=>’Gambar’,
     ‘type’=>’raw’,
     ‘value’=>’CHtml::image(Yii::app()->baseUrl.$data->image, \’DORE\’, array(“width”=>50))’,
),
...

0

#3 User is offline   _mifta 

  • Newbie
  • Yii
  • Group: Members
  • Posts: 6
  • Joined: 06-March 13
  • Location:Surabaya

Posted 08 March 2013 - 03:00 AM

Kok masih gk bisa tampil ya mas??
Apa baseUrl nya perlu di deklarasiin dulu??

ini potongan script abis diedit:
array(
                
                'name'=>'Gambar',
                'type'=>'raw',           
                'value'=>'CHtml::image(Yii::app()->baseUrl.$data->foto, \'DORE\', array("width"=>50))',
            ),

0

#4 User is offline   C.S.Putera 

  • Junior Member
  • Pip
  • Yii
  • Group: Members
  • Posts: 92
  • Joined: 18-May 11

Posted 08 March 2013 - 05:43 AM

Oya ? Wah, harusnya bisa sih :blink: baseUrl tidak perlu dideklarasikan dulu, itu fungsi bawaan dari Yii. Yang disimpan di kolom foto adalah path dari imagenya benar ? Apakah agan yakin gambarnya sudah tersimpan dan path nya sudah tersimpan dengan benar ? :)
0

#5 User is offline   Nur Rochim 

  • Junior Member
  • Pip
  • Yii
  • Group: Members
  • Posts: 42
  • Joined: 04-February 13
  • Location:Indonesia

Posted 08 March 2013 - 10:23 PM

Quote

//Baca dari dbnya
$TS=User::model()->findByPk($model->user_id);
$link='a/../../namafolder/'.$TS->namafolder;
array(
CHtml::link(CHtml::image($link, 'DORE', array("width"=>80)), '#');

Contoh hasilnya seperti ini:
[Lihat di attachments]

Attached File(s)


0

Share this topic:


Page 1 of 1
  • You cannot start a new topic
  • You cannot reply to this topic

1 User(s) are reading this topic
0 members, 1 guests, 0 anonymous users