Welcome Guest, Not a member yet? Register   Sign In
Displaying dynamic form data

[eluser]Chris Williams[/eluser]
After going through the tutorials, I wanted to make a form that was table driven. So the input names come from values of a record set.

Without knowing those names, how do I display $_POST data? Is there helper in CodeIgniter for this?

Can you elaborate??

I'm not sure if i got right the first part of your post.

To display $_POST data you do this in the controller:

$data['name']= $this->input->post('name');
// this is the same as $data['name'] = $_POST['name'];

//then you pass it to the view:


then in your view file:

Your name is :<?=$name?>

Was that your question?

[eluser]Chris Williams[/eluser]
Right. I wasn't sure if there was a helper built in for this or not. Basically, my database populates the form which changes week to week. So I can't hard code any of it.

I am using this for dynamically made forms. It works, I didn't know if there was a smarter way around this.

foreach ($_POST as $i => $someVar)
    if ($someVar != 0){
        $query = $this->db->query("SELECT name, id FROM mytable WHERE id = $i");
        foreach ($query->result() as $row)
           $body .= $row->name . " x " . $someVar . "<br />";
$data['body'] = $body;

Theme © iAndrew 2016 - Forum software by © MyBB