[eluser]Yanny[/eluser]
Hi all,
I know how to re-populate the form with post data, via set_value('fieldname');
Now I want to re-populate the form with post data again but the post data contains data from the database. How to do that?
Normally without using framework I will do something like this:
Code:
//when there are not post values do this
if (!isset($_POST)) {
//get data from the database with a sql query
$rs = mysql_query("The query goes here");
//put the data in the post variables
$row = mysql_fetch_assoc($rs);
$_POST['username'] = $row['username'];
$_POST['email'] = $row['email'];
}
//display the form with post data
<form>
*Username: <input type="text" name="username" value='<?php echo $_POST['username'];?>' /><br />
*Email: <input type="text" name="email" value='<?php echo $_POST['email'];?>' />
</form>
So how to do this now with CodeIgniter?
I have tried something like this:
Code:
$this->input->post('username') = $data['user']['username'];
$data['user']['username'] is a value from the database, but it does not work.
I know you guys know how to do it, since this is a common thing. Thanks in advance!