Welcome Guest, Not a member yet? Register   Sign In
Submit td
#1

Dear all,

I am trying to submit some data from a table, in order to insert those to my db. But unfortunately I don't get anything from my table. Here is some code to understand my problem:


View:
Code:
<?php echo form_open('controller/add') ?>
    <table>
        <tr>
            <td><input type="hidden" name="rowValue[]"/>1</td>
            <td>
                <input type="hidden" name="seatValue[]"/>
                <select>
                    <option value="1">1</option>
                    <!--some more values-->
                </select>
            </td>
        </tr>
    </table>
    <button type="submit">Submit</button>
<?php echo form_close ?>

Controller function add:
Code:
public function add() {
    if(isset($_POST)) {
        $row = $_POST['rowValue'][0];
        $seat = $_POST['seatValue'][0];
    }
    $this->add_model->add_r_s($row, $seat);

Model function to insert into db:
Code:
public function add_r_s($row, $seat) {
    $fields = array ($row, $seat)
    $this->db->insert('table_name', $fields);
}
I am using "rowValue[]" in the view, because obviously I have some more <td>-tags in my view.
I don't understand why it doesn't get the submit from the view, because when I try print_r($row); I don't get anything.
What am I missing?

Cheers
Reply
#2

Hi,
You need to add the value to your hidden input.
A good decision is based on knowledge and not on numbers. - Plato

Reply
#3

You'll have to give the <select></select> element a name. Otherwise, the selected value will not be POSTed.
Reply
#4

He should have a name= for his submit button also.
What did you Try? What did you Get? What did you Expect?

Joined CodeIgniter Community 2009.  ( Skype: insitfx )
Reply




Theme © iAndrew 2016 - Forum software by © MyBB