Can not take value from view on codeigniter

1399 views php

I've been working on this codeigniter php app for my class and I have a view where you can select a quantity of a coin and the selected quantity comes back as a null.

my controller:

public function add(){

    $this->form_validation->set_rules('quantity', 'Quantity', 'required');


    $inventorycoin = $this->uri->segment('3');
    $inventoryquantity = $this->input->post('quantity');

        $this->coin_model->add_coin($inventorycoin, $inventoryquantity);
        //$this->session->set_flashdata('post_deleted', 'Post has been deleted');

my model:

public function add_coin($inventorycoin, $inventoryquantity){

        $data = array (
            'inventory_user' =>  $this->session->userdata('user_id'),
            'inventory_quantity' => $inventoryquantity,
            'inventory_coin' => $inventorycoin

        return $this->db->insert('inventory', $data);

my view:

<?php echo form_open_multipart('coins/add', 'id="coins"'); ?>
<table width="100%">

<?php foreach($coins as $coin) : ?>
            <td><img  class="post-thumbnail"  src="<?php echo site_url(); ?>assets/images/coins/<?php echo $coin['coin_image']; ?>"></td>
            <td><?php echo $coin['coin_name']; ?></td>
            <td><?php echo $coin['coin_country']; ?></td>
            <td><?php echo $coin['coin_weight']; ?></td>
            <td><input type="number" min="0" name="quantity" placeholder="Qt" ></td>
            <td><p><a class="btn btn-primary" href="<?php echo base_url(); ?>coins/add/<?php echo $coin['coin_id']; ?>">Add</a></p></td>
<?php endforeach; ?>


What could be the problem?

answered question

1 Answer


public function add($coin_id){

posted this

Have an answer?


Please login first before posting an answer.