Mysql
 sql >> Teknologi Basis Data >  >> RDS >> Mysql

Tangkap nilai elemen HTML dalam tabel dinamis

Koreksi Saya Jika saya tidak salah.. Di sini Anda ingin mendapatkan semua nilai dari formulir Benar? di klik tombol kirim?Mengapa Anda membuat tombol ini href?Misalkan kita memiliki 3 data ke dalam $result dan loop saya terlihat seperti di bawah ini

 <form method="post" action="">
<tr>
       <td scope="row"></td>
       <input type ="text" name="sourece" value=1 />
              <td>                         
                    <input type="number" class="form-control" id="shift1PinCount" name="shift1PinCount" placeholder="Pin Count" title="Please key in Pin Count for Shift 1" min=0>
              </td>

              <td>
                    <input type="text" class="form-control" id="shift1Oa" name="shift1Oa" value="1" disabled>
              </td>

              <td>
                    <input type="number" class="form-control" id="shift2PinCount" name="shift2PinCount" placeholder="Pin Count" title="Please key in Pin Count for Shift 2" min=0>
              </td>

              <td>
                    <input type="text" class="form-control" id="shift2Oa" name="shift2Oa" value="2" disabled>
              </td>

              <td>
                    <input type="number" class="form-control" id="shift3PinCount" name="shift3PinCount" placeholder="Pin Count" title="Please key in Pin Count for Shift 3" min=0>
              </td>

              <td>
                    <input type="text" class="form-control" id="shift3Oa" name="shift3Oa" value="3" disabled>
              </td>

              <td>
                    <input type="number" class="form-control" id="shift4PinCount" name="shift4PinCount" placeholder="Pin Count" title="Please key in Pin Count for Shift 4" min=0>
              </td>

              <td>
                    <input type="text" class="form-control" id="shift4Oa" name="shift4Oa" value="4" disabled>
              </td>

              <td><input class="form-control" type="date" id="shiftDate" name="shiftDate" value="<?=date("Y-m-d")?>"></td>

              <td>
                <input type="submit" class="btn btn-primary" name="savePcData" id="savePcData" value="savePcData">
              </td> 
</form>
</tr>
<form method="post" action="">
<tr>
       <td scope="row"></td>
       <input type ="text" name="sourece" value=2 />
              <td>                         
                    <input type="number" class="form-control" id="shift1PinCount" name="shift1PinCount" placeholder="Pin Count" title="Please key in Pin Count for Shift 1" min=0>
              </td>

              <td>
                    <input type="text" class="form-control" id="shift1Oa" name="shift1Oa" value="11" disabled>
              </td>

              <td>
                    <input type="number" class="form-control" id="shift2PinCount" name="shift2PinCount" placeholder="Pin Count" title="Please key in Pin Count for Shift 2" min=0>
              </td>

              <td>
                    <input type="text" class="form-control" id="shift2Oa" name="shift2Oa" value="22" disabled>
              </td>

              <td>
                    <input type="number" class="form-control" id="shift3PinCount" name="shift3PinCount" placeholder="Pin Count" title="Please key in Pin Count for Shift 3" min=0>
              </td>

              <td>
                    <input type="text" class="form-control" id="shift3Oa" name="shift3Oa" value="33" disabled>
              </td>

              <td>
                    <input type="number" class="form-control" id="shift4PinCount" name="shift4PinCount" placeholder="Pin Count" title="Please key in Pin Count for Shift 4" min=0>
              </td>

              <td>
                    <input type="text" class="form-control" id="shift4Oa" name="shift4Oa" value="44" disabled>
              </td>

              <td><input class="form-control" type="date" id="shiftDate" name="shiftDate" value="<?=date("Y-m-d")?>"></td>

              <td>
                <input type="submit" class="btn btn-primary" name="savePcData" id="savePcData" value="savePcData">
              </td> 
</form>
</tr>
<form method="post" action="">
<tr>
       <td scope="row"></td>
       <input type ="text" name="sourece" value=3 />
              <td>                         
                    <input type="number" class="form-control" id="shift1PinCount" name="shift1PinCount" placeholder="Pin Count" title="Please key in Pin Count for Shift 1" min=0>
              </td>

              <td>
                    <input type="text" class="form-control" id="shift1Oa" name="shift1Oa" value="111" disabled>
              </td>

              <td>
                    <input type="number" class="form-control" id="shift2PinCount" name="shift2PinCount" placeholder="Pin Count" title="Please key in Pin Count for Shift 2" min=0>
              </td>

              <td>
                    <input type="text" class="form-control" id="shift2Oa" name="shift2Oa" value="222" disabled>
              </td>

              <td>
                    <input type="number" class="form-control" id="shift3PinCount" name="shift3PinCount" placeholder="Pin Count" title="Please key in Pin Count for Shift 3" min=0>
              </td>

              <td>
                    <input type="text" class="form-control" id="shift3Oa" name="shift3Oa" value="333" disabled>
              </td>

              <td>
                    <input type="number" class="form-control" id="shift4PinCount" name="shift4PinCount" placeholder="Pin Count" title="Please key in Pin Count for Shift 4" min=0>
              </td>

              <td>
                    <input type="text" class="form-control" id="shift4Oa" name="shift4Oa" value="444" disabled>
              </td>

              <td><input class="form-control" type="date" id="shiftDate" name="shiftDate" value="<?=date("Y-m-d")?>"></td>

              <td>
                <input type="submit" class="btn btn-primary" name="savePcData" id="savePcData" value="savePcData">
              </td> 
</form>
</tr>

<?php

if(isset($_POST['savePcData'])){

    echo "<pre>";
    print_r($_POST);
    die('mms');

}


?> 

Keluaran Anda akan menjadi

di sini sumber adalah ID unik Anda yang membantu Anda memperbarui data ke dalam DB Anda

Setelah mengirimkan formulir dari tr(baris) mana pun, Anda akan dialihkan ke halaman yang sama dengan metode POST dan mendapatkan data untuk baris tertentu di halaman itu sehingga Anda dapat dengan mudah memperbaruinya sesuai keinginan

Anda dapat memeriksa ini dengan menggunakan print_r($_POST); di halaman yang sama

Jika Anda memiliki pertanyaan, jangan ragu untuk bertanya kepada saya...




  1. Database
  2.   
  3. Mysql
  4.   
  5. Oracle
  6.   
  7. Sqlserver
  8.   
  9. PostgreSQL
  10.   
  11. Access
  12.   
  13. SQLite
  14.   
  15. MariaDB
  1. Kunci tabel mysql dengan php

  2. Mysql:tidak mungkin diperhatikan setelah membaca tabel const

  3. Permintaan bergabung dengan MySQL

  4. pilih setiap baris lain di MySQL tanpa bergantung pada ID apa pun?

  5. ASP.NET/Identity Error:ApplicationUser tipe entitas bukan bagian dari model untuk konteks saat ini