Note that there are some explanatory texts on larger screens.

plurals
  1. POHow to call a value from function set_value in Code Igniter?
    primarykey
    data
    text
    <p>I 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> <pre><code> &lt;!-- update_view.php --&gt; &lt;!DOCTYPE html&gt; &lt;html&gt; &lt;head&gt; &lt;title&gt;&lt;/title&gt; &lt;/head&gt; &lt;body&gt; &lt;h2&gt;Update&lt;/h2&gt; &lt;?php echo form_open('site/update'); ?&gt; &lt;p&gt; &lt;label&gt;Judul : &lt;/label&gt; &lt;input type="text" name="judul" id="judul" value="&lt;?php echo set_value('judul','??')?&gt;"/&gt; &lt;/p&gt; &lt;p&gt; &lt;label&gt;Konten : &lt;/label&gt; &lt;input type="text" name="konten" id="konten" size="100px" value="&lt;?php echo set_value('konten','??')?&gt;"/&gt; &lt;/p&gt; &lt;p&gt;&lt;input type="submit" value="Ubah" /&gt;&lt;/p&gt; &lt;?php echo form_close(); ?&gt; &lt;/body&gt; &lt;/html&gt; </code></pre> <p>What 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> <pre><code> &lt;!-- options_view.php --&gt; &lt;!DOCTYPE html&gt; &lt;html&gt; &lt;head&gt; &lt;title&gt;&lt;/title&gt; &lt;/head&gt; &lt;body&gt; &lt;h2&gt;Create&lt;/h2&gt; &lt;?php echo form_open('site/create'); ?&gt; &lt;p&gt; &lt;label&gt;Judul : &lt;/label&gt; &lt;input type="text" name="judul" id="judul" /&gt; &lt;/p&gt; &lt;p&gt; &lt;label&gt;Konten : &lt;/label&gt; &lt;input type="text" name="konten" id="konten" size="100px"/&gt; &lt;/p&gt; &lt;p&gt;&lt;input type="submit" value="Simpan" /&gt;&lt;/p&gt; &lt;?php echo form_close(); ?&gt; &lt;hr/&gt; &lt;h2&gt;Read&lt;/h2&gt; &lt;?php if(isset($records)): foreach($records as $baris) : ?&gt; &lt;h3&gt;&lt;?php echo $baris-&gt;judul ?&gt;&lt;/h3&gt; &lt;div&gt;&lt;?php echo $baris-&gt;konten ?&gt;&lt;/div&gt; &lt;?php echo anchor("site/view_update/$baris-&gt;id","[Update]"); ?&gt; &lt;?php echo anchor("site/delete/$baris-&gt;id","[Delete]"); ?&gt; &lt;?php endforeach; ?&gt; &lt;?php else : ?&gt; &lt;h3&gt;Tidak ada data.&lt;/h3&gt; &lt;?php endif; ?&gt; &lt;/body&gt; &lt;/html&gt; </code></pre> <p>i'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>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload