我在这段代码中遇到了问题。我已经编写了代码并附上了截图,你必须在查看屏幕截图后更清楚。当你必须看截图时,请看更新查询并显示序列值是错误的。
但我认为序列值显示哪个复选框是勾号。
这是序列数组:
Array
(
[0] => 09
[1] => 45
[2] => 76
)
这是复选框值:
Array
(
[0] => 1
[1] => 3
)
当我更新查询复选框时,值显示正确,但序列值显示错误。
<table id="contentTable">
<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 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 :(得分: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以获取示例。