Can not take value from view on codeigniter

1399 views php
-1

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');

    if(!$this->session->userdata('logged_in')){
        redirect('users/login');
    }

    $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');
        redirect('coins');
    }

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) : ?>
            <tr>
            <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>
            </tr>   
<?php endforeach; ?>

        </table>
        </form>

What could be the problem?

answered question

1 Answer

6

public function add($coin_id){

posted this

Have an answer?

JD

Please login first before posting an answer.