edit and add logic |
Hello,
Can anyone help me do this? This is my add_pages form which I would like to use for editing also. Therefore if someone from pages.php click button add the below add_pages.php form appears with empty form and if the user click edit button. The previous data will loads in add_pages.php in value="" therefore should be an if statement. If someone click edit button --> therefore should be a certain value in value="". How to write the correct if statement or code? Thanks in advance. views/add_pages.php PHP Code: <table border="0" style="width: 100%; height: 90px;"> controllers/cpages.php PHP Code: public function addpages()
" If I looks more intelligence please increase my reputation."
(06-23-2016, 04:48 AM)JayAdra Wrote: Read. The. Docs. Agreed he should read the docs, but that link does not help in this case. He wants to populate fields with values from a DB record. @davy_yg First: Don't use tables for layout. Use divs Now as for code, your question has little to do with CI and more with PHP in general. Your page will need a flag telling it if it is in ADD mode OR EDIT mode. In ADD mode you could set an empty array with key names that match your field names. Use this array in your view setting each value. PHP Code: value="<?php echo $record['page_name']; ?>" In EDIT mode you will fill the empty array with the correct values, thus your form will have the values set for editing
Thanks I have read the docs.
Another thing that I am confuse, look at this one: I try to click the edit button and nothing happen. It does not bring me to the next page either. How to make the edit button brings me to the next pages? views/pages.php PHP Code: <?php foreach ($pages as $pages_item): ?> views/add_pages.php PHP Code: <table border="0" style="width: 100%; height: 90px;">
" If I looks more intelligence please increase my reputation."
Maybe this will help:
PHP Code: <div id="login"> What did you Try? What did you Get? What did you Expect?
Joined CodeIgniter Community 2009. ( Skype: insitfx )
Here is something I've proposed before about add/edit logic implementation: http://forum.codeigniter.com/thread-6514...#pid331960
|
Welcome Guest, Not a member yet? Register Sign In |