php - submitting multiple rows to database with one form in codeigniter -
i'm trying create bulk edit page app i'm working on. table contains rows of products each of have 3 editable fields.
<tr> <input type="hidden" name="id" value="10"> <td>sku<td> <td>product name</td> <td> <select name="product_category" value="" tabindex="4"> <option value="1">category 1</option> <option value="2">category 2</option> </select> </td> <td><input type="text" name="current_inventory" class="short" value="15" tabindex="5"></td> <td><input type="text" name="inventory_alert" class="short" value="6" id="inventory_alert" tabindex="6"></td> </tr>
every row can edited , there 1 submit button on page. how should format correctly can update each entry in database values? thanks.
you can use arrays form names php
<input type="text" name="product[current_inventory]" class="short" value="15" tabindex="5"> ...
when process form can use
foreach( $_post['product'] $product ) { $current_inventory = $product['current_inventory']; // sql statement update product }
Comments
Post a Comment