vendredi 17 mars 2017

How Can I Set ''Insert data into the database from checkbox array using Codeigniter''

I have a problem I want to be checkbox, How can I change, Thank you.

User will choose items. For exemple;

item 1
item 5 item 6

and there is a button on bottom form. When user click, it will add Marked items.

controllers Code:

    public function relationAddForm($relation, $user)
    {
        if ($this->input->post()) {
            
            $id = $this->input->post("id");
            $success = $this->account_model->recordInsertRelation($relation, $user->id, $id);

            if ($success) {
                $this->site->log('RELATION', "Hizmet Eklendi. #{$relation}-{$id} | #{$user->id}|{$user->email}", "user/{$user->id}");
                $this->site->set_alert('success', lang("form-success-relation-add"));
                redirect("hesabim/hizmet/ekle/{$relation}");
            }
        }
    }

PHP form Codes:

<?php if (empty($records)): ?>
                        <tr>
                            <td colspan="2" class="alignCenter"><?php echo sprintf(lang("page-relation-add-no-data-{$this->uri->segment(4)}"), $user->bolum->baslik) ?></td>
                        </tr>
                    <?php else: ?>
                        <?php foreach ($records as $item): ?>
                            <tr>
                                <td><?php echo $item->baslik ?></td>
                                <td>
                                    <form class="form accountForm validate" method="post" action="" accept-charset="utf-8">
                                        <input type="hidden" name="type" value="data" />
                                        <input type="hidden" name="id" value="<?php echo $item->id ?>" />
                                        <button class="button buttonGreen radius4" type="submit"><?php echo lang("form-button-account-add") ?></button>
                                    </form>
                                </td>
                            </tr>
                        <?php endforeach; ?>
                    <?php endif; ?>
                </table>
            </div>
        </div>



Aucun commentaire:

Enregistrer un commentaire