简体   繁体   中英

How do I send HTML table data to php code

I have some input fields and one html table in a form and I want to send all data including all rows from the table to php function in a codeigniter controller. my table data is filled dynamically by using javascript.

 <form method="POST" >

                <input type="text" class="form-control" id="pname" placeholder="Enter Patient name here" name="pname"  >

                <input type="number" class="form-control" id="p-age" name="p-age"  >
 
            <input type="radio" id="male" name="sex" value="male"  >
            <label for="male" class="receipt-label mr-2">Male</label>

            <input type="radio" id="female" name="sex" value="female"  >
            <label for="female" class="receipt-label mr-2">Female</label>


        <table class="table" id="dest_table" >
        <thead class="thead-dark">
          <tr>
          <th scope="col">Test ID</th>
            <th scope="col">Test Name</th>
            <th scope="col">Price</th>
            <th scope="col" style="text-align:center;">Action</th>
          </tr>
        </thead>
        <tbody>
                    </tbody>
                    </table>



        <button type="submit" name="submit" class="btn btn-info btn-lg" id = "submit">Print</button>                    

       </form>               

Just add some hidden fields in the table

<form method="POST" >
    
                    <input type="text" class="form-control" id="pname" placeholder="Enter Patient name here" name="pname"  >
    
                    <input type="number" class="form-control" id="p-age" name="p-age"  >
     
                <input type="radio" id="male" name="sex" value="male"  >
                <label for="male" class="receipt-label mr-2">Male</label>
    
                <input type="radio" id="female" name="sex" value="female"  >
                <label for="female" class="receipt-label mr-2">Female</label>
    
    
            <table class="table" id="dest_table" >
            <input type="hidden" name="hid-box" value="1" /> 
            <thead class="thead-dark">
              <tr>
              <th scope="col">Test ID</th>
                <th scope="col">Test Name</th>
                <th scope="col">Price</th>
                <th scope="col" style="text-align:center;">Action</th>
              </tr>
            </thead>
            <tbody>
                        </tbody>
                        </table>
    
    
    
            <button type="submit" name="submit" class="btn btn-info btn-lg" id = "submit">Print</button>                    
    
           </form> 

          

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM