0

My controller function:

public function c_content()
{
    $data['story_id']=$this->input->post('story_id');
    $data['template_id']=$this->input->post('template_id');
    $data['content']=$this->input->post('content');
    $ary_len=count($data); // give me output 1 where as i send 3 value 
    echo $ary_len;
}

From here I send value story id, template id and content, where as the content have a multiple input values.

My view:

<form action="<?=base_url('c_signup/c_content')?>" method="post" >
    <input type="text" name='template_id' value=<?php echo  $template_id ?> >
    <input type="text" id="story_id" name='story_id' value=<?php echo $story_id ?> >

    <div class="abc">

    <?php
        $story_content1=$txt;

        // here some code is exected and give me result 3
        $result = count($out); // output 3

        for ($x = 0; $x < $result; $x++) {
            echo("
                  <input type='text' value='". $out[$x] ."' name='content'>// here i set name of txt field as content
            ");
    ?>
    <?php
        }
    ?>

    </div>
    <button value="submit">save</button>
</form>
2
  • 2
    So what's your problem? Commented Nov 22, 2016 at 12:57
  • i will send 3 values as an array from my view in content field but in controller it will only display 1 .. Commented Nov 22, 2016 at 13:13

2 Answers 2

0

Try this

<input type='text' value='". $out[$x] ."' name='content[]'>
Sign up to request clarification or add additional context in comments.

Comments

0

You are counting the entire $data array, not $data['content'].

I believe you want $ary_len = count($data['content']); in your PHP.

You'll need to also change name="content" to name="content[]" in your HTML.

Look at this answer for an explanation on what happens when you count an associative array.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.