Welcome Guest, Not a member yet? Register   Sign In
edit and add logic
#1

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;">
                            <tr>
                                <td>Pages Name:</td>
                                <td><input type="input" name="pages_name"
                                value="
                                
                                <?php
                                
                                echo 
$this->pages_model->get_pages();
                                
                                ?>
                                
                                ></td>
                            </tr>
                            <!--
                            <tr>
                                <td>Create Date:</td>
                                <td><input type="
input" name="create_date" size="2"></td>
                            </tr> -->                            
                            <tr>
                                <td>Order:</td>
                                <td><input type="
input" name="pages_order" size="4"></td>
                            </tr>
                            <tr>
                                <td></td>
                                <td><input type="
submit" name="submit" value="Submit" /></td>
                            </tr>    
                        </table>        




controllers/cpages.php


PHP Code:
    public function addpages() 
    { 
 
        
        
        $this
->form_validation->set_rules('pages_name''pages_name''required');
        
$this->form_validation->set_rules('create_date''create_date''required');
        
$this->form_validation->set_rules('pages_order''pages_order''required');
        
$this->form_validation->set_rules('pages_content''pages_order''required');
        
                
                
            if (
$this->form_validation->run() === FALSE)
            {
            
$this->load->view('add_pages');
            }
                
            else
            {
            
$this->pages_model->insert_pages();        
            
$this->load->view('add_pages');                
            }
                        
         
 
    
    
}
    
    public function 
editpages()
    {
        
         
   $data['show'] = $this->pages_model->get_pages(); 
        
            
$this->load->view('add_pages'$data);    
            
    } 
" If I looks more intelligence please increase my reputation."
Reply


Messages In This Thread
edit and add logic - by davy_yg - 06-23-2016, 04:42 AM
RE: edit and add logic - by JayAdra - 06-23-2016, 04:48 AM
RE: edit and add logic - by Martin7483 - 06-23-2016, 05:59 AM
RE: edit and add logic - by davy_yg - 06-23-2016, 06:36 AM
RE: edit and add logic - by InsiteFX - 06-23-2016, 11:20 AM
RE: edit and add logic - by ivantcholakov - 06-23-2016, 02:34 PM



Theme © iAndrew 2016 - Forum software by © MyBB