Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/arrays/14.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Php 我试图将一个数组从我的控制器传递到标记中的view部分,以显示选项-不工作_Php_Arrays_Database_Codeigniter_Insert - Fatal编程技术网

Php 我试图将一个数组从我的控制器传递到标记中的view部分,以显示选项-不工作

Php 我试图将一个数组从我的控制器传递到标记中的view部分,以显示选项-不工作,php,arrays,database,codeigniter,insert,Php,Arrays,Database,Codeigniter,Insert,我试图将一个数组从我的控制器传递到标记中的视图部分,以显示选项-不工作 在没有表单验证和模型在数据库中插入值的情况下,它以前是工作的。如果表单验证已从控制器中删除,则表单将直接提交,其中的空值显示错误列。\u name不能为空。我的代码有什么问题?请帮帮我 iam将阵列传递到我的视图的控制器 在数据库中插入值的模型 视图:这是iam通过数组的窗体 在控制器中,加载视图,然后将其重定向到其他视图 $this->load->view('templates/pheader'); $this

我试图将一个数组从我的控制器传递到标记中的视图部分,以显示选项-不工作 在没有表单验证和模型在数据库中插入值的情况下,它以前是工作的。如果表单验证已从控制器中删除,则表单将直接提交,其中的空值显示错误列。\u name不能为空。我的代码有什么问题?请帮帮我

iam将阵列传递到我的视图的控制器

在数据库中插入值的模型

视图:这是iam通过数组的窗体


在控制器中,加载视图,然后将其重定向到其他视图

$this->load->view('templates/pheader');
$this->load->view('profile/editskill', $dataArr);
$this->load->view('templates/pfooter');

$this->profile_model->insert_skill(); //put this line before you load the views
redirect('profile/vabout'); //you can remove this line
因此,将这些行重新排列为

$this->profile_model->insert_skill();
$this->load->view('templates/pheader');
$this->load->view('profile/editskill', $dataArr);
$this->load->view('templates/pfooter');

您不需要在控制器中使用两个不同的函数来提交表单,您可以使用单个函数来完成,您只需要检查表单是否已提交,然后插入代码,否则显示正常视图

如果您想重定向到另一个页面,而不是为什么要加载视图“have_done”和“work”的输入/选择在哪里?
<form method="post" id="editskill" action="<?php echo base_url(); ?>profile/getskill" name="editskill">
    <div class="form-group">
        <label class="col-md-3 text-right">I give my best:</label>
        <div class="col-md-9">
            <select class="chosen-select"
                    name="give_my_best"
                    data-placeholder="Give best"
                    tabindex="6"
                    id=""
                    multiple="multiple">
                <?php foreach($give_my_best as $value) { ?>
                <option value="<?php echo $value; ?>"><?php echo $value; ?></option>
                <?php } ?>
            </select>
        </div>
    </div>
    <br><br><br>
    <div class="form-group">
        <label class="col-md-3 text-right">Skills:</label>
        <div class="col-md-9">
            <select class="chosen-select" name="skills" data-placeholder="Skills" tabindex="6" id=""
                    multiple="multiple">
                <optgroup label="On Stage">
                    <?php foreach($OnStage as $value) { ?>
                    <option value="<?php echo $value; ?>"><?php echo $value; ?></option>
                    <?php } ?>
                </optgroup>
                <optgroup label="Back Stage">
                    <?php foreach($BackStage as $value) { ?>
                    <option value="<?php echo $value; ?>"><?php echo $value; ?></option>
                    <?php } ?>
                </optgroup>
                <optgroup label="Services">
                    <?php foreach($Services as $value) { ?>
                    <option value="<?php echo $value; ?>"><?php echo $value; ?></option>
                    <?php } ?>
                </optgroup>
            </select>
        </div>
    </div>
    <br><br>
    </div> <!-- Angular JS ends here -->
    <div class="form-group">
        <button type="submit"
                class="btn btn-primary col-md-7 col-md-offset-3 text-right"
                id="submit"
                value="submit"
                name="submit">Submit
        </button>
    </div>
</form>
$this->load->view('templates/pheader');
$this->load->view('profile/editskill', $dataArr);
$this->load->view('templates/pfooter');

$this->profile_model->insert_skill(); //put this line before you load the views
redirect('profile/vabout'); //you can remove this line
$this->profile_model->insert_skill();
$this->load->view('templates/pheader');
$this->load->view('profile/editskill', $dataArr);
$this->load->view('templates/pfooter');