Home > Blockchain >  How to bind value inside the input field?
How to bind value inside the input field?

Time:07-06

I am using codeigniter-3 for developing the web apps, i have one update or edit form i am passing the data to the view file but the data is not binding in UI (input field is empty),can you help me where did i mistake..?

print_r($data)

Array ( [0] => stdClass Object ( [id] => 14 [book_id] => test_565 [book_name] => Pelerin [book_number] => 2323232 [address] => ssss  [status] => 1 ) ) 

controller.php

$data = $res->stations;
//return print_r($data);
$this->load->view('edit-book',$data);

edit-book.php

 <input type="text" name="product_title"  value="<?php echo $data[stations]->book_name;?>" id="exampleInputName1" placeholder="">

CodePudding user response:

Assign the key value based before sending the data to view file like following

$data['data'] = $res->stations;

In view file

value="<?php echo $data[0]->book_name;?>" 

CodePudding user response:

Change in your controller,

$data = array("stations"=>$res->stations);
$this->load->view('edit-book',$data);

And in view,

<input type="text" name="product_title"  value="<?php echo $stations[0]->book_name;?>" id="exampleInputName1" placeholder="">
  • Related