Passing values from a Select Multiple to the bank (Codeigniter)

Asked

Viewed 146 times

0

My view is like this:

<div class="form-group">
    <label for="categorias[]">Selecione a(s) categoria(s) referente(s) a foto:</label>
    <select name="categorias[]" class="form-control" multiple="multiple" required>
        <?php foreach ($listarCategorias->result() as $row) : ?>
            <option value="<?php echo $row->idCategoria; ?>"><?php echo $row->dscCategoria; ?></option>
        <?php endforeach ?>
    </select>
</div>

What the code of my controller/model would look like for the values of this select to be recorded one in each row in my database table?

  • passes to a json and stores

1 answer

2

A possibility would be the following within your controller/model:

$array['categorias'] = $this->input->post('categorias');
foreach ($array['categorias'] as $value) {
    echo $value;
}

Browser other questions tagged

You are not signed in. Login or sign up in order to post.