2016-03-08 57 views
0

我在這個代碼中遇到了問題。我已經編寫了代碼,並附上了屏幕截圖,您必須在查看屏幕截圖後清除更多內容。當你必須看到截圖時,請查看更新查詢並顯示順序值是錯誤的。我面臨的問題在陣列

但我認爲序列值顯示哪個複選框是打勾的。

這是序列數組:

Array 
(
    [0] => 09 
    [1] => 45 
    [2] => 76 
) 

這是複選框值:

Array 
(
    [0] => 1 
    [1] => 3 
) 

當我更新所述查詢複選框值表示正確的,但序列值被表示錯誤。以下功能根據自己的需要


          
  
 <table id="contentTable"> 
 

 
    \t \t \t \t \t \t \t \t \t \t \t \t \t <tr> 
 
                  <td id="formCreateLabel"> 
 
                  <label for="learnTabname"><strong>Show on Home page</strong></label></td> 
 
                  <td id="formCreateLabel" style="float: left"><strong>Testimonial Name</strong></td> 
 
                  <td><strong>Sequence</strong></td> 
 
                  </tr> 
 

 
    <?php \t for ($counter=1; $counter<=4; $counter++) {?> 
 
    <tr> 
 
                   <td align="center" ><input type="checkbox" name="t1[]" value="<?php echo $counter;?>" id="t1[]" <?php if($row_getThisRecord['isFeatured']==1){ ?> checked="checked"<?php } ?> /></td> 
 
                   <td style="float: left;margin-left:44px;"><?php echo "TEST a".$counter?></td> 
 
                   <td><input type="text" style="width:30px" name="isSeq[]" value="0" id="isSeq[]" /></td> 
 
                  </tr> 
 
      <?php }?>            
 

 
       </table>
[enter image description here][1] My Php code:- <?php $id = $_POST['t1']; $isSeq = $_POST['isSeq']; echo "This is the sequence array:"; echo "<pre>"; print_r($isSeq); echo "</pre>"; echo "<BR>"; echo "this is the checkbox value:"; echo '<pre>'; print_r($id); echo '<pre>'; for ($indx = 0 ; $indx < count($id); $indx ++) { $sregion=$id[$indx]; $isSequence=$isSeq[$indx]; echo $queryUpdate="update abc set isFeatured=1,isSequence='$isSequence' where abcID='$sregion'"; $updateAbc=mysql_query($queryUpdate,) or die(mysql_error()); } ?>

回答

0

使用一個: -

sort() - sort arrays in ascending order 
rsort() - sort arrays in descending order 
asort() - sort associative arrays in ascending order, according to the value 
ksort() - sort associative arrays in ascending order, according to the key 
arsort() - sort associative arrays in descending order, according to the value 
krsort() - sort associative arrays in descending order, according to the key 

請參閱本documentation的例子。