douhao2026 2017-09-26 05:43
浏览 42
已采纳

Php阵列发布错误

I have an array with 1200 records, But when I submit the form the code counts 250 records in the array. Why?

This is the code:

<?php
if (isset($_POST['ok'])) {
    echo count($_POST['precios']);
    // showme only 250 récords
}
?>
<form method='POST' action='productos.php'>
    <button class="btn green"  type="submit" name="ok"> Actualizar de forma masiva</button>
    <?php
    $query4334x = "select * from Productos";

    $result_categorias4334x = mysql_db_query($dbname, $query4334x)
        or die("Failed Query of " . $query4334x);  //guardo en una variable los registros obtenidos con el query

    $numero5 = mysql_num_rows($result_categorias4334x);
    echo $numero5;
    // showme 1200 récords

    while ($row = mysql_fetch_array($result_categorias4334x)) {
        $precio = $row['Precio'];
        ?>
        <input type="text" name="precios[]" value="<?php echo $precio; ?>">
        <?php
    }
    ?>
</form>
  • 写回答

4条回答 默认 最新

  • duanjian4150 2017-09-26 06:02
    关注

    If you can't change settings in your php.ini max_input_vars and post_max_size

    Try Something like below which works for me

    implode() the array into one long string and explode() it on the server side.

    json_encode() could probably work as well.

    Example:

    while ($row = mysql_fetch_array($result_categorias4334x)) {
            $precio[] = $row['Precio'];
        }
    <input type="text" name="precios" value="<?php echo implode(",",$precio); ?>">
    

    //POST

    <?php
    if (isset($_POST['ok'])) {
        $precios = $_POST['precios'];
        $preciosarr = explode(",", $precios);
        print_r($preciosarr);
    }
    ?>
    

    NOTE: The maximum number of characters allowed in the element. Default value is 524288

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(3条)

报告相同问题?

悬赏问题

  • ¥15 想问一下树莓派接上显示屏后出现如图所示画面,是什么问题导致的
  • ¥100 嵌入式系统基于PIC16F882和热敏电阻的数字温度计
  • ¥15 cmd cl 0x000007b
  • ¥20 BAPI_PR_CHANGE how to add account assignment information for service line
  • ¥500 火焰左右视图、视差(基于双目相机)
  • ¥100 set_link_state
  • ¥15 虚幻5 UE美术毛发渲染
  • ¥15 CVRP 图论 物流运输优化
  • ¥15 Tableau online 嵌入ppt失败
  • ¥100 支付宝网页转账系统不识别账号