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

Popular posts from this blog

c++ - Convert big endian to little endian when reading from a binary file -

C#: Application without a window or taskbar item (background app) that can still use Console.WriteLine() -

unicode - Are email addresses allowed to contain non-alphanumeric characters? -