[eluser]HugoA[/eluser]
Hi. I'm trying to make a form with some input controls and i need to put some info in those controls so the user can change the data. Basically what I'm doing is retrieve some data from the data base and then i need to put that data in the input fields. How can i do this?
this is mi view
Code:
<head>
<title>Formulario</title>
<link rel="stylesheet" href="<?php echo base_url();?>system/css/style.css" type="text/css" media="screen"
charset="utf-8">
</head>
<body>
<div id="container">
<h1>Ejemplo de Formulario</h1>
<?php
echo form_open('formulario/crearUsuario');
?>
<fieldset>
<legend>Informacion Personal</legend>
<table>
<tr>
<td>
<?php echo form_label('Nombre:','labelNombre')?>
</td>
<td>
<?php
$nombreConfig = array(
'name' => 'nombre',
'id' => 'nombre',
'maxlength' => '10');
echo form_input($nombreConfig)
?>
</td>
</tr>
<tr>
<td>
<?php echo form_label('Apellido:','labelApellido')?>
</td>
<td>
<?php
$apellidoConfig = array(
'name' => 'apellido',
'id' => 'apellido',
'maxlength' => '10');
echo form_input($apellidoConfig)
?>
</td>
</tr>
<tr>
<td>
<?php echo form_label('Super Clave:','labelSuperClave')?>
</td>
<td>
<?php
$passwordConfig = array(
'name' => 'clave',
'id' => 'clave',
'maxlength' => '10',);
echo form_password($passwordConfig)
?>
</td>
</tr>
</table>
</fieldset>
<?php echo form_close()?>
</div>
</body>
this is the controller
Code:
<?php
class Formulario extends Controller{
function index()
{
$data = array();
$this->load->model('formulario_model');
if($query = $this->formulario_model->obtener_usuario())
{
$data['records'] = $query;
}
$this->load->view('formulario_view',$data);
}
}
?>
and this is the model
Code:
<?php
class Formulario_model extends Model{
function obtener_usuario()
{
$this->db->where('idpersona','1');
$query = $this->db->get('persona');
if($query->num_rows() > 0){
foreach($query->result() as $row){
$data[] = $row;
}
return $data;
}
}
}
?>
Thanks!