尝试将复选框结果加载到CodeIgniter中的iFrame中

时间:2016-05-25 10:52:04

标签: codeigniter iframe checkbox

我正在尝试学习CodeIgniter。我想从我的视图(index.php)发送复选框值,通过我的控制器(也称为index.php,令人困惑,但这就是我工作的公司所称的,这是一个好主意吗?), iFrame(在我的视图中有一个名为results.php的文件)。到目前为止,我在视图上得到一个数组,但只显示了键 - 没有复选框的值 - 如下所示:

Array ( [resultsAreaCode] => [resultsNumberType] => [resultsOrder] => [fred] => DAVE [sheep] => cow ) TEST

以下是我的复选框和目标iframe视图,请注意PHP / SQL填充了一个复选框:

  <form id="numberOrderForm" action="index/localNumberResults" method="post" enctype='multipart/form-data'>
    <div class="wrappers" id="multi-select1Wrapper">
        <h2>Area Code</h2>
        <select class="dropDownMenus" id="multi-select1" name="multi_select1[]" multiple="multiple">
            <?php
                //The query asking from our database
                $areaCodeSQL = "SELECT ac.Number AS `AreaCode`, ac.Name AS `AreaName`
                                FROM `AreaCodes` ac";                                                               //SQL query: From the table 'AreaCodes' select 'Number' and put into 'AreaCode', select Name and put into 'AreaName'

                $areaCodeResults = $conn->query($areaCodeSQL);                                                      // put results of SQL query into this variable

                if ($areaCodeResults->num_rows > 0) {                                                               // if num_rows(from $results) is greater than 0, then do this:
                    // output data of each row
                                foreach($areaCodeResults as $areaCodeResult)                                        //for each item in $areCodeResults do this:
                                    {
                                        $areaNameAndCode =  $areaCodeResult['AreaCode'] ." ". $areaCodeResult['AreaName'];  //get AreaCode and AreaName from query result and concat them
                                        $areaName = $areaCodeResult['AreaName'];                                    // get AreaName
                                        $areaCode = $areaCodeResult['AreaCode'];                                    //get AreaCode

                                        ?><option class="menuoption1" name="menuAreaCode" value="<?php echo $areaCode ?>"  ><?php echo $areaNameAndCode; ?></option><?php  //Create this option element populated with query result variables
                                    }
                } 

            ?>
        </select>
    </div>       




    <div class="wrappers" id="multi-select2Wrapper">
        <h2>Number Type</h2>
        <select class="dropDownMenus" id="multi-select2" name="multi_select2[]" multiple="multiple">
            <option class="menuoption2" name="package" value="gold">Gold</option>
            <option class="menuoption2" name="package" value="silver">Silver</option>
            <option class="menuoption2" name="package" value="bronze">Bronze</option>
        </select>
    </div>

    <div class="wrappers" id="multi-select3Wrapper">
        <h2>Order</h2>
        <select class="dropDownMenus" id="multi-select3" name="multi_select3[]" >
            <option class="menuoption3" name="order" value="sequential">Sequential</option>
            <option class="menuoption3" name="order" value="random">Random</option>
        </select>
    </div>  
    <input type="submit" value="Submit">
</form>

<div id="resultsTableWrapper">
    <iframe id="resultsTable" src="http://my-company.com/localNumberResults" width="100%"></iframe> 
</div>

这是在我的控制器内(我的导师告诉我这是正确的):

class Index extends CI_Controller { // this is my controller!


public function localNumberResults()
    {
    $data['formdata']= array(
                        'resultsAreaCode' => $this->input->post("menuAreaCode"), 
                        'resultsNumberType' => $this->input->post("package"), 
                        'resultsOrder' => $this->input->post("order"),
                        'fred' => 'DAVE', 
                        'sheep' => 'cow'
                        );



    $data['contentlocation'] = 'system/results';
    $this->load->view('system/template', $data);

    }
}

任何人都可以指出我正确的方向我错了吗? : - )

0 个答案:

没有答案