adamking008 Posted March 11, 2014 Share Posted March 11, 2014 Hi i am a bit of a codeigniter newbie, I need a set of values inserting to a databse table, the inputs are created via a foreach loop. <? foreach ($items as $item){echo' <div class="items-row"> <label for="name_'.$item['item_id'].'">'.$item['item_name'].'</label> <div class="item_input"><input type="text" name="quantity[]" id="'.$item['item_name'].'" value="0"></div> <input type="hidden" name="item_id" value="'.$item['item_id'].'"> <input type="hidden" name="user_id" value="'.$moving_basics_id.'"> </div>'; }?> Each item is displayed with a Quanity toggle, and a user id and item id. How would i go about inserting each value into a database table? Thanks Adam Quote Link to comment https://forums.phpfreaks.com/topic/286876-adding-values-from-looped-input-fields/ Share on other sites More sharing options...
PravinS Posted March 11, 2014 Share Posted March 11, 2014 give name as array for each field, as <?php foreach ($items as $item) { echo'<div class="items-row"> <label for="name_'.$item['item_id'].'">'.$item['item_name'].'</label> <div class="item_input"><input type="text" name="quantity[]" id="'.$item['item_name'].'" value="0"></div> <input type="hidden" name="item_ids[]" value="'.$item['item_id'].'"> <input type="hidden" name="user_ids[]" value="'.$moving_basics_id.'"> </div>'; } ?> Quote Link to comment https://forums.phpfreaks.com/topic/286876-adding-values-from-looped-input-fields/#findComment-1472126 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.