Reputation: 17
In my cart I have a value that I need send to order_items, I have sent my variable to view and it's displaying correctly, but when save order, the value return NULL. I have checked all data, but probably the problem is how I'm sending.
Controller:
$dataProdutos['detalhesEstoque'] = $this->produtos_model->detalhesEstoque('23');
View: Displaying correctly.
<?= $detalhesEstoque[0]->codprod ?>
How I'm trying to send to MySQL using this variable:
$detalhesEstoque[0]->codprod;
Upvotes: 1
Views: 55
Reputation: 169
You can send variable data from your view to controller then save to database using POST method
for example at view
<form action="<?php echo site_url('datasave/save_action'); ?>" method="post">
<input type="text" class="form-control" name="codprod" id="codprod" value="<?php echo $detalhesEstoque[0]->codprod; ?>" readonly ?>
</form>
at controller
public function save_action()
{
$data= array(
'codprod' => $this->input->post('codprod',TRUE),
);
$this->Codprod_model->insert($data);
at model
function insert($data)
{
$this->db->insert('codprodtable', $data);
}
Upvotes: 2