I
I
Ivan Drozhzhin2017-05-25 20:25:50
PHP
Ivan Drozhzhin, 2017-05-25 20:25:50

Why did data stop being written to the database after line 200?

The point is the following.
The page displays pickup points from the database (so far 208 items) in the form of a table-form.
On this page, you can change the field values ​​arbitrarily (displayed as inputs) and there is a "Save" button.
Starting from the 200th pickup point and further, the data is not recorded in the database. Just refreshing the page.
Here is the code:

if ((isset($_REQUEST['point_id'][0])) && ($_REQUEST['point_id'][0]>0)) {
       
      $sizearcount = sizeof($_REQUEST['point_id']);
      for($i=0;$i<$sizearcount;$i++)
      {
         $this->db->query("UPDATE `" . DB_PREFIX . "pickup_point` SET point_iml = '" . $this->db->escape($_REQUEST['point_iml'][$i]) . "', 
          city_iml = '" . $this->db->escape($_REQUEST['city_iml'][$i]) . "' WHERE pickup_point_id = '" . (int)$_REQUEST['point_id'][$i] . "'");

      }
       
     }
    
    
    // Выдача
    $query = $this->db->query("SELECT * FROM " . DB_PREFIX . "pickup_point ORDER BY pickup_point_id");
    $ords = $query->rows;
    
    foreach ($ords as $result) {
      
        $this->data['orders'][] = array(
        'point_id'      => $result['pickup_point_id'],
        'point_name'      => $result['point_name'],
        'point_addres'        => $result['point_address'],
        'point_iml'        => $result['point_iml'],
        'city_iml' => $result['city_iml']
      );
    }

<div class="content">
      <form action="" method="post" enctype="multipart/form-data" id="form">
        <table class="list">
          <thead>
            <tr>
              
              <td class="left">Название</td>              
              <td class="left">Адрес пункта</td>
              <td class="left">IML код пункта самовывоза</td>
        <td class="left">IML регион пункта самовывоза</td>
       
              <td class="right"><?php echo $column_action; ?></td>
            </tr>
          </thead>
          <tbody>

            <?php if ($orders) { ?>
            <?php foreach ($orders as $order) { 

      ?>
            <tr>

              <td class="left">
        <input type="hidden" name="point_id[]" value="<?php echo $order['point_id']; ?>">
        <input type="text" name="point_name[]" value="<?php echo $order['point_name']; ?>">
        </td>
              <td class="left">
        <input type="text" name="point_addres[]" value="<?php echo $order['point_addres']; ?>">
        </td>
              <td class="left">
         <input type="text" name="point_iml[]" value="<?php echo $order['point_iml']; ?>" >
         </td>
              <td class="left">
        <input type="text" name="city_iml[]" value="<?php echo $order['city_iml']; ?>">
        </td>
             

              <td class="right"><br>
        <input type="submit" value="Сохранить">
        
        </td>
            </tr>
            <?php } ?>
            <?php } else { ?>
            <tr>
              <td class="center" colspan="8"><?php echo $text_no_results; ?></td>
            </tr>
            <?php } ?>
          </tbody>
        </table>
      </form>

The real question is: how?

Answer the question

In order to leave comments, you need to log in

2 answer(s)
I
Immortal_pony, 2017-05-25
@RotarYMonkeY

The exact reason is unknown to me, but there is a strong suspicion that the problem is related to the number of UPDATEs.
All changes can be made in one request. For this you can use, for example, the construction
INSERT INTO ... ON DUPLICATE KEY UPDATE

T
Tokenchik, 2017-05-25
@Tokenchik

Try increasing the script execution time in the server settings.
And when printing in code, it is more convenient to use not your constructs in the code through curly braces, but through a colon:

<?php if ($orders) : ?>
    <?php foreach ($orders as $order) :  ?>
        <?= $order['point_id'];  ?>
    <?php endforeach;  ?>
<?php else : ?>
<?php endif; ?>

Readability is many times higher, no need to catch brackets.
Here about it

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question