0

I have a problem with my submit form.

This is my controller [offering_member] :

function offering_member {
$idTransaksi = $this->uri->segment(3); //$idTransaksi = 1
$data['anotheruser'] = $this->m_transaksi->getDataUserOffer($idTransaksi)->result(); //parameter $idTransaksi

$this->template_user->display('user/offeringbook/view_offeringbyuser', $data);
}

This is my model [getDataUserOffer] :

function getDataUserOffer($idTransaksi){ //$idTransaksi = 1
    $this->db->select('*');
    $this->db->from('tr_offer');
    $this->db->select("DATE_FORMAT(tgl_gabung, '%b %d, %Y') AS tgl_gabung", FALSE);
    $this->db->where('tr_offer.id_transaksi', $idTransaksi);
    $this->db->join('user', 'user.id_user = tr_offer.id_user');

    $query = $this->db->get();

    return $query;
}

tr_offer table :

id_offer | id_transaksi | id_user | tgl_offer

    1    |      1      |     7     |   2014-09-25
    3    |      1      |     1     |   2014-09-28

And this is my view [view_offeringbyuser.php] :

 <?php $no=0; foreach($anotheruser as $row): $no++;?>
            <form class="form-horizontal" action="<?php echo site_url('user/offermethod/'.$row->id_transaksi .'/'. $row->id_offer); ?>" method="post" />                
                <div>
                    <img src="<?php echo base_url ('assets/img/user/'.$row->foto); ?>" data-toggle="modal" data-target="<?php echo'#myModal'.$row->id_offer; ?>" alt="..." width="100" height="120">
                </div>          
                <div>
                    <a href='<?php echo site_url('user/member/'.$row->username.'/');?>'><?php echo $row->username; ?></a>
                    <input type="text" class="form-control" name="<?php echo 'idOffer'.$no; ?>" value="<?php echo $row->id_offer; ?>">
                </div>
                <center>
                    <input name="hhh" value="<?php echo 'submit'. $no; ?>" type="submit" class="btn btn-primary"><i class="glyphicon glyphicon-chevron-right"></i> </button>
                </center>
            </div>
<?php endforeach; ?>

This view will display :

>    Photo[1] | Photo[2] ---> image
> 
>      ddd[1] | eee[2] ---> username
>
>         1   |    3  ---> input text value id_offer
> 
> Submit1 [1] | Submit2 [2] ---> submit button form

When I click Submit1, action will direct to http://domain/user/offermethod/1/1

But when I click Submit2, also direct to http://domain/user/offermethod/1/1 << this is should be 3

I think the problem was in the submit form looping. Input text display true value. But why the action form just set $row->id_offer = 1, event you click Submit2 button

I'm sorry for my bad english, Thanks.

1 Answer 1

0

You need to close the form

 <?php $no=0; foreach($anotheruser as $row): $no++;?>
            <form class="form-horizontal" action="<?php echo site_url('user/offermethod/'.$row->id_transaksi .'/'. $row->id_offer); ?>" method="post" />                
                <div>
                    <img src="<?php echo base_url ('assets/img/user/'.$row->foto); ?>" data-toggle="modal" data-target="<?php echo'#myModal'.$row->id_offer; ?>" alt="..." width="100" height="120">
                </div>          
                <div>
                    <a href='<?php echo site_url('user/member/'.$row->username.'/');?>'><?php echo $row->username; ?></a>
                    <input type="text" class="form-control" name="<?php echo 'idOffer'.$no; ?>" value="<?php echo $row->id_offer; ?>">
                </div>
                <center>
                    <input name="hhh" value="<?php echo 'submit'. $no; ?>" type="submit" class="btn btn-primary"><i class="glyphicon glyphicon-chevron-right"></i> </button>
                </center>
            </div>
<?php echo form_close(); ?> /* Close the form here */
<?php endforeach; ?>
Sign up to request clarification or add additional context in comments.

1 Comment

Oh my. I've been looking for it for 1 hour. And the answer just need 1 line. Thank you so much senk. How to give you some reputation?

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.