I am trying to build a bidding application. I want to a associate a textfield with the primary key of the row outputted. e.g textfield is bid_amount
.
When entering the bid amount I want the bid_amount
entered and the person who bid (truckerid
) and the product bid on (luggage_id
) to be stored in a bids table.
The outputted products to bid for are stored in another table (consignment table) Below is my model, view and controller.
View
<h2 class="page-header">
<i class="fa fa-legal"></i>   <font color="orange"> Loads To Bid For </font>
</h2>
</div><!-- /.col -->
</div>
<?php
foreach ($h->result() as $row) {}
?>
<div class="row invoice-info">
<div class="col-sm-1 invoice-col">
</div>
<div class="col-sm-3 invoice-col">
<img src="<?php echo base_url()?>/res/images/goods/1.png">
</div>
<div class="col-sm-4 invoice-col">
<address>
Description: <?php echo $row->description;?><br>
Location Address: <?php echo $row->l_area;?><br>
Destination Address: <?php echo $row->d_area;?><br>
Date: <?php echo $row->dom;?><br>
Time: <?php echo $row->tom;?>
</address>
</div>
<div class="col-sm-2 invoice-col">
<address>
</address>
</div><!-- /.col -->
<div class="col-sm-2 invoice-col">
<?php echo form_open('truckeraccount_ctrl/bid'); ?>
<input type="hidden" class="form-control" name="truckerid" value="<?php
$truckerid = $this->session->userdata('truckerid');
echo $truckerid; ?>" required>
<input type="text" class="form-control" name="bid_amount[$row->luggage_id]" placeholder="Bid">
<button type="submit" class="btn bg-orange btn-flat margin">Place Bid</button>
</div>
</div>
Controller
public function bid() {
$this->load->model('Truckeraccount_model');
// $luggage_id = $this->uri->segment(3);
$this->Truckeraccount_model->bid();
redirect('truckeraccount_ctrl');
}
Model
function bid() {
$data = array(
'luggage_id' => $this->input->post('luggage_id'),
'bid_amount' => $this->input->post('bid_amount'),
'truckerid' => $this->input->post('truckerid')
);
//$this->db->where('luggage_id', $luggage_id);
$query=$this->db->update('bids', $data);
return $query;
}