bcamp1973 Posted April 7, 2006 Share Posted April 7, 2006 I have a list like this....[code]<ul><li><input type="checkbox" name="sku" value="257" />whatever</li><li><input type="checkbox" name="sku" value="271" />something</li><li><input type="checkbox" name="sku" value="272" />bla</li></ul>[/code]then i have the following code to submit whatever checked in the list along with a few other fields[code]if(isset($_POST['submit'])) { reqForm('name'); reqForm('brand_id','brand'); if($formSubmit) { @mysql_query( "UPDATE collections SET ". "name = '{$_POST['name']}', ". "department = '{$_POST['department']}', ". "brand_id = '{$_POST['brand_id']}' ". "WHERE id = '{$_GET['collectionid']}'" ) OR mkQueryError('UPDATE DETAILS'); if($_POST['sku']) { foreach($_POST['sku'] as $sku) { if($sku !== '') { @mysql_query("INSERT INTO collection_skus (collection_id,sku_id) VALUES ('{$_GET['collectionid']}',$sku)") OR mkQueryError('ADD SKUS'); } else { @mysql_query("DELETE FROM collection_skus WHERE collection_id = '{$_GET['collectionid']}' AND sku_id = $sku") OR mkQueryError('REMOVE SKUS'); } } } }}[/code]so far all i get is the following error...[code]Invalid argument supplied for foreach()[/code]what am i missing? Link to comment https://forums.phpfreaks.com/topic/6836-solved-inserting-multiple-records/ Share on other sites More sharing options...
bcamp1973 Posted April 7, 2006 Author Share Posted April 7, 2006 i solved it....i'm an idiot...it's becuase the list needs to look like this...[code]<li><input type="checkbox" name="sku[]" value="257" />whatever</li>[/code] not this[code]<li><input type="checkbox" name="sku" value="257" />whatever</li>[/code] Link to comment https://forums.phpfreaks.com/topic/6836-solved-inserting-multiple-records/#findComment-24845 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.