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 2020长安杯与连接网探
  • ¥15 关于#matlab#的问题:在模糊控制器中选出线路信息,在simulink中根据线路信息生成速度时间目标曲线(初速度为20m/s,15秒后减为0的速度时间图像)我想问线路信息是什么
  • ¥15 banner广告展示设置多少时间不怎么会消耗用户价值
  • ¥16 mybatis的代理对象无法通过@Autowired装填
  • ¥15 可见光定位matlab仿真
  • ¥15 arduino 四自由度机械臂
  • ¥15 wordpress 产品图片 GIF 没法显示
  • ¥15 求三国群英传pl国战时间的修改方法
  • ¥15 matlab代码代写,需写出详细代码,代价私
  • ¥15 ROS系统搭建请教(跨境电商用途)