CodeIgniter Forums
Insert with While/Foreach - Printable Version

+- CodeIgniter Forums (
+-- Forum: General (
+--- Forum: Regional User Groups (
+--- Thread: Insert with While/Foreach (/thread-78786.html)

Insert with While/Foreach - Germanikus - 03-10-2021

Hello all,
I am desperately looking for a solution, but I can't find one.
I have this insert in my model

<?php echo form_open('setup/insert_step006'); ?>
<button type="submit" class="btn btn-danger">Speichern</button>
<?php foreach ($view_old_auflage as $auflage): ?>
<div class="input-group mb-3 input-group-sm">
    <input type="<?php echo $input; ?>" class="form-control" name="add_setup_000[<?php echo $auflage['auflage_id']; ?>]" value="<?php echo $auflage['auflage_id']; ?>">
    <input type="<?php echo $input; ?>" class="form-control" name="add_setup_001[<?php echo $auflage['auflage_id']; ?>]" value="<?php echo $auflage['auflage_name']; ?>">
<?php foreach ($view_old_tcg as $tcg): ?>
    <input type="<?php echo $input; ?>" class="form-control" name="add_setup_00<?php echo $tcg['tcg_id'] + 1; ?>[<?php echo $auflage['auflage_id']; ?>]" value="<?php echo $auflage['auflage_'.$tcg['tcg_short'].'']; ?>">
<?php endforeach; ?>
<?php endforeach; ?>
<?php echo form_close(); ?>

PHP Code:
            foreach ($this->input->post('add_setup_000') as $setup_000) {
$result $this->db->get('db_auflage');
$result->num_rows() < 1) {
$data = array(    'tb_auflage_name' => $this->input->post('add_setup_001')[$setup_000],
'tb_auflage_ygo' => $this->input->post('add_setup_002')[$setup_000],
'tb_auflage_mtg' => $this->input->post('add_setup_003')[$setup_000],
'tb_auflage_pkm' => $this->input->post('add_setup_004')[$setup_000],

I want to put the part from "tb_auflage_ygo" in a loop, like in the view.
But I can't figure out how to do that.
Do you have a solution?