Welcome Guest, Not a member yet? Register   Sign In
problem with update
#1

[eluser]mo2men[/eluser]
hi
i want update one row from mysql

i want do this with my code

select all rows
than
select row that equal id i send it With anchor
and
show row in forms to edit and
update it

if error

show forms and validation error again


in my code
forms not show because i use foreach



my code

model
Code:
function get_edit($gp_id){
                $this->db->select('*');
                $this->db->from('content');
                $this->db->where('id',$gp_id);
                $query = $this->db->get();
                 return $query->result();
     }

controller
Code:
function index(){
        $gp_id = $this->uri->segment(3);
        $data['row'] =  $this->options->get_edit($gp_id);

        $data['sidebar'] = 'inside-sidebar';
        $data['site_content'] = 'edit_page';
        $this->load->view('include/template',$data);

    }
    function do_edit(){
        
          $this->form_validation->set_rules('title', 'Title', 'trim|required|min_length[6]max_length[100]|xss_clean');
        $this->form_validation->set_rules('description', 'description', 'trim|required|min_length[20]|xss_clean');
                $this->form_validation->set_rules('payout', 'Payout', 'trim|required|min_length[6]max_length[100]|xss_clean');
        

                if($this->form_validation->run() == FALSE){
                    $this->index();
                }
                else{
                    echo "yes";
                }

than show
in view with foreach
Code:
echo form_open('edit/do_edit');

foreach($row as $read) :


echo "<label><b style='margin-right:75px; font-size:16px; '>Title : </b></label>" .form_input('title', set_value('title',$read->title))."<br />";

$textarea = Array ("name" => "description","id" => "description" ,"value" => 'rrr');
echo "<b style='margin-right:79px; font-size:16px'>your descripion : </b>" .form_textarea($textarea)."<br />";


?&gt;

        </div>
    
<div  style="margin-left: 30em; margin-bottom: 20px; display: block;">&lt;? echo form_submit('submit', 'share link');?&gt;</div>
&lt;?php endforeach;?&gt;




Theme © iAndrew 2016 - Forum software by © MyBB