2017-06-30 5 views
1

"KOHANA FRAMEWORK"ボタンを選択すると、チェックボックスの選択値の取得方法とデータベースへの挿入方法が表示されます。 マイページには2つのフィールドのテキストボックスと2つ目のチェックボックスがあります。 チェックボックスとテキストボックスの値を挿入しようとしましたが、テキストボックスの値は取得できますが、チェックボックスの値は取得できません。「コナナフレームワーク」で複数のチェックボックス値を取得する方法は?

=====>純粋なPHPと同様にadd.php

<?php echo form::open('backend/notifications/add/', array('enctype' => 'multipart/form-data')) ?> 

<div class="staffWrapper"> 

      <h2 style="float: left;">List Companies</h2> 
      <div class="clear"></div> 



      <table style="width:100%; table-layout:fixed;" border="0"> 
       <tr> 
        <th width="20"><input type='checkbox' id='selectall' style='width:15px;'/></th> 
        <th width="210">Name</th> 
        <th width="100">Contact Person</th> 
        <th width="100">Phone</th> 
        <th width="210">Email</th> 
        <!-- <th width="80" colspan="2">Actions</th> --> 
       </tr> 

       <?php 
       if (count($companies)) { 
        $i = (isset($_GET['page']) ? ($_GET['page']-1)*50+1 : 1); 
        foreach ($companies as $company) {  

         echo $i % 2 ? '<tr class="even">' : '<tr class="odd">'; 
         // echo "<td align='center'>" . $i . "</td>"; 
         echo "<td align='center'>"; 
         echo '<input type="checkbox" id="PILIH" name="PILIH[]" class="PILIH" value='.$company['id'].' style="width:15px;"/>'; 
         echo "</td>"; 
         echo "<td>" . $company['name'] . "</td>"; 
         echo "<td>" . $company['contact_person'] . "</td>"; 
         echo "<td>" . $company['phone'] . "</td>"; 
         echo "<td>" . $company['email'] . "</td>"; 
         $i++; 
        } 
       } else if (empty ($companies) && $searchKey){ 
        echo '<tr class="odd">'; 
        echo '<td colspan="7" align="center"><h3>No mathcing results were found for this search term.</h3></td>'; 
        echo '</tr>'; 
       } else if (empty ($companies)){  
        echo '<tr class="odd">'; 
        echo '<td colspan="7" align="center"><h3>There are no companies.</h3></td>'; 
        echo '</tr>'; 
       } 
       ?> 
      </table> 

     <?php echo $pagination; ?> 
     </div> 

<div class="clear"></div> 

    <div style="float:right; margin-right: 335px; padding:10px 0 10px 0;"> 
     <?php echo form::submit('', 'Create Notifications', array('class' => 'submit')) ?> 
    </div> 

    <div class="clear"></div> 
    <?php echo form::close(); ?> 

答えて

0

$PILIH = !empty($_POST['PILIH'])?$_POST['PILIH']:Array(); // pure PHP 
$PILIH = Array::get($_POST, 'PILIH', Array()); 
$PILIH = $this->request->post('PILIH', Array()); //Where $this is Controller 
$PILIH = Request::current()->post('PILIH', Array()); 

その結果、あなたはそう、会社-IDまたは空の配列から配列を取得します:

$company_id = NULL; 
$q = DB::query(Databse::INSERT, 'INSERT INTO foo (company_id) VALUES (:company_id)')->bind(':company_id', $company_id); 
foreach($PILIH AS $company_id) { 
    $q->execute(); 
} 

あなたはとてもすぎ入力、与えていない:幸せなコード分析を。 AndRTFM

関連する問題