Reputation: 1109
I am new to codeigniter. I am stuck somewhere in displaying the value retrieved from database! How can I display the value extracted from Database into the Textbox using Codeigniter ?
My view is : PutArtistProfile_v
<?php
foreach ($return_Name as $row )
{
echo '<input type="text" name="Name" id="Name" />';
}
?>
My Controller is:
public function index($return_Name)
{
$this->load->view('PutArtistProfile_v', $return_Name );
}
$return_Name -- have data fetched from database.
Upvotes: 1
Views: 6374
Reputation: 1128
You can access your data from session variables from controller
$data['id'] = $this->session->userdata('user_id');
And in view you can echo it out in input fields
<input type="text" name="id_admin" value="<?php echo $id; ?>" maxlength="50" class="form-control" />
Upvotes: 1
Reputation: 406
You can pass the data to view using controller method
public function index()
{
$data['return_data'] = $this->model_name->function_name();
$this->load->view('view_filename', $data );
}
And in view you can access the value using loop
foreach($return_data as $row)
{
echo '<input type="text" name="name" value="$row['column_name']" /';
}
Upvotes: 1
Reputation: 1979
<?php
foreach($return_Name as $key)
{
$val= $key->text_name;
echo "<input type='text' value='$val' />";
}
?>
Upvotes: 1
Reputation: 1856
You have to send your result to view:
In controller:
public function index($return_Name)
{
$data['return_Name'] = $return_Name;
$this->load->view('PutArtistProfile_v', $data );
}
In view you can get data like $return_Name
Upvotes: 1
Reputation: 2042
In View -
<?php
foreach ($return_Name as $row )
{
echo '<input type="text" name="Name" id="Name" value="$row->columnname" />';
}
?>
Upvotes: 1