0

I want to save my input values into a 2D array.

<table>
  <?php
    $kriteria = array('IP', 'SE', 'PE', 'BE');

  ?>
    <thead>
      <tr>
        <th>Kriteria</th>
        <?php
           foreach ($kriteria as $val) {
              echo '<th>' . $val . '</th>';
           }
        ?>
      </tr>
    </thead>
    <tbody>
      <?php $n = count($kriteria); ?>
      <?php for ($i = 0; $i < $n; $i++): ?>
      <tr>
        <th>
          <?= $kriteria[$i] ?>
        </th>
        <?php for ($j = 0; $j < $n; $j++): ?>
        <td><input type="text" class="form-control" id="<?= $kriteria[$j] . $kriteria[$i] ?>" name="<?= $j. $i ?>" value=""></td>
        <?php endfor; ?>
      </tr>
      <?php endfor; ?>
    </tbody>
</table>

I tried with the POST method but it didn't work.

I want to use the value from the input for counting in another page.

this the result enter image description here

1
  • 1
    When you say I tried with the POST method what exactly have you tried? Commented Dec 17, 2019 at 8:55

1 Answer 1

1

I want to use the value from the input for counting in another page.

public function page1()
{
    $kriteria = json_encode(array('IP', 'SE', 'PE', 'BE'));
    $temp = sys_get_temp_dir() . '/tmp_file_123';
    file_put_contents($temp, $kriteria);
}

public function page2()
{
    $temp = sys_get_temp_dir() . '/tmp_file_123';
    $kriteria = file_get_contents($temp);
}
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.