Wednesday 2 October 2013

How to call a value from function set_value in Code Igniter?

How to call a value from function set_value in Code Igniter?

pI have a simple task , and i'm using a MVC methods and CI framework for
this task. I have made a view to input data to database, and it's work,
and i make a 2 anchors, those are an [Update] and [Delete], the function
delete is working, but the update isn't working. After user click anchor
[Update], it will linked to another view(update_view), and i want to show
the content which i've clicked in the (update_view). and i think it use a
set_value to set a second parameter, to show a value in my update_view.
This is my code in a view(update_view)/p precodegt; lt;!-- update_view.php
--gt; gt; lt;!DOCTYPE htmlgt; gt; lt;htmlgt; gt; lt;headgt; gt;
lt;titlegt;lt;/titlegt; gt; lt;/headgt; gt; lt;bodygt; gt;
lt;h2gt;Updatelt;/h2gt; gt; lt;?php echo form_open('site/update'); ?gt;
gt; lt;pgt; gt; lt;labelgt;Judul : lt;/labelgt; gt; lt;input type=text
name=judul id=judul value=lt;?php echo set_value('judul','??')?gt;/gt; gt;
lt;/pgt; gt; lt;pgt; gt; lt;labelgt;Konten : lt;/labelgt; gt; lt;input
type=text name=konten id=konten size=100px value=lt;?php echo
set_value('konten','??')?gt;/gt; gt; lt;/pgt; gt; lt;pgt;lt;input
type=submit value=Ubah /gt;lt;/pgt; gt; lt;?php echo form_close(); ?gt;
gt; lt;/bodygt; gt; lt;/htmlgt; /code/pre pWhat should i put in input tag
in value attributes, i want to show a value in input fields (judul,
konten) from page before where i clicked the anchors. I still can't show a
image for a view before click, because i'm still don't have 10 rep to
share images. so i'will show the coding where the view(options_view) i've
clicked the anchors. This below is the code in a view(options_view) :/p
precodegt; lt;!-- options_view.php --gt; gt; lt;!DOCTYPE htmlgt; gt;
lt;htmlgt; gt; lt;headgt; gt; lt;titlegt;lt;/titlegt; gt; lt;/headgt; gt;
lt;bodygt; gt; lt;h2gt;Createlt;/h2gt; gt; lt;?php echo
form_open('site/create'); ?gt; gt; lt;pgt; gt; lt;labelgt;Judul :
lt;/labelgt; gt; lt;input type=text name=judul id=judul /gt; gt; lt;/pgt;
gt; lt;pgt; gt; lt;labelgt;Konten : lt;/labelgt; gt; lt;input type=text
name=konten id=konten size=100px/gt; gt; lt;/pgt; gt; lt;pgt;lt;input
type=submit value=Simpan /gt;lt;/pgt; gt; lt;?php echo form_close(); ?gt;
gt; lt;hr/gt; gt; lt;h2gt;Readlt;/h2gt; gt; lt;?php if(isset($records)):
foreach($records as $baris) : ?gt; gt; lt;h3gt;lt;?php echo
$baris-gt;judul ?gt;lt;/h3gt; gt; lt;divgt;lt;?php echo $baris-gt;konten
?gt;lt;/divgt; gt; lt;?php echo
anchor(site/view_update/$baris-gt;id,[Update]); ?gt; gt; lt;?php echo
anchor(site/delete/$baris-gt;id,[Delete]); ?gt; gt; lt;?php endforeach;
?gt; gt; lt;?php else : ?gt; gt; lt;h3gt;Tidak ada data.lt;/h3gt; gt;
lt;?php endif; ?gt; gt; lt;/bodygt; gt; lt;/htmlgt; /code/pre pi'm still
doubt, whether i should add code in my controller or my view(set_value).
So anyone can help me to solve this problem. Thank's for help/p

No comments:

Post a Comment