dqrb4228 2015-07-24 14:16
浏览 31
已采纳

使用非顺序键时,阵列限制为1,001个键

I pull two IDs from a database via a query. One is the table's unique primary key (temp_id), and one is not (auto_id). The query gives me 1,477 records.

When I add these to an array like so, and then var_dump() the array, I get the full 1,477:

<input type="checkbox" name="temp_id[]" value="<?=$auto_id?>">

However when I use this code, suddenly the array only contains 1,001:

<input type="checkbox" name="temp_id[<?=$temp_id?>]" value="<?=$auto_id?>">

Is there any inherent reason for this? As far as I can tell, because $temp_id is unique, this should not cause any "clashes" in the data, or overwritten keys.

FORM CODE:

<?php
if (!isset($_GET['date']) || !filter_var($_GET['date'], FILTER_VALIDATE_INT)) {
    header("Location: ./");
    exit();
}
$date = $_GET['date'];
$upload_date = gmdate("Y-m-d H:i:s", $date);
require_once("db.php");

$automatch_query = mysql_query("SELECT temp_id, auto_id FROM advertisers INNER JOIN update_tempdata ON advertisers.advertiser_id = update_tempdata.auto_id WHERE auto_id > 0 AND upload_date = '$upload_date' ORDER BY advertiser_name");
?>
<form action="match-auto-script.php" method="post">
    <?php
    while ($automatch_data = mysql_fetch_assoc($automatch_query)) {
        extract($automatch_data);
        ?>
        <input class="toggleable" type="checkbox" name="temp_id[<?=$temp_id?>]" value="<?=$auto_id?>" checked>
        <?php
    }
    ?>
</form>

SCRIPT:

<pre><?php var_dump($_POST); ?></pre>
  • 写回答

1条回答 默认 最新

  • douzi115522 2015-07-24 15:39
    关注

    With thanks to @DCoder's links to answers in other threads, I use the following solution:

    <input type="checkbox" name="temp_id[][<?=$temp_id?>]" value="<?=$auto_id?>" checked>
    

    This gives me all 1,477 records as their own array, but at least I have crucial links between each unique temp_id and non-unique auto_id.

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥16 Qphython 用xlrd读取excel报错
  • ¥15 单片机学习顺序问题!!
  • ¥15 ikuai客户端多拨vpn,重启总是有个别重拨不上
  • ¥20 关于#anlogic#sdram#的问题,如何解决?(关键词-performance)
  • ¥15 相敏解调 matlab
  • ¥15 求lingo代码和思路
  • ¥15 公交车和无人机协同运输
  • ¥15 stm32代码移植没反应
  • ¥15 matlab基于pde算法图像修复,为什么只能对示例图像有效
  • ¥100 连续两帧图像高速减法