theWheeler Posted January 14, 2008 Share Posted January 14, 2008 Hi! Basicly, this is what I´m trying to do: I have a form with several languages which is categories. Each category has several options and each option is what how many menu-items the user have created for the language. Each language can have several items, and others can have just one... I want to set a standard for each language among these several options to set as primary to use. Each option is an <input type="radio" -box and has a unique id. Because of there are several items in each category I have given each input a category-name, like: name="standard_sv[]" (for swedish) and name="standard_en[]" (for english). I collect all my id´s that I have selected from the form when submitted the form and put the id´s into an array. But when I trying to loop for each value (id) with foreach and trying to store it in the database (mysql), it doesn´t store anything. I have bean sitting here for more then 2 days and can´t solve the problem or see what´s wrong with it... I have my id´s in the array and so on... and the function sees the array... So I don´t know wy??? Please help... Here some code: <?php function Set_Menu_Standard() { global $standard; $sql = "UPDATE nq_menu SET nq_menu.static='0'"; mysql_query($sql) or die (mysql_error($sql)); foreach($standard as $strd) { $sql = "UPDATE nq_menu SET nq_menu.static='1' WHERE nq_menu.id='$strd'"; mysql_query($sql) or die (mysql_error($sql)); } } if(isset($_POST['usemenu'])) { $lang = List_Lang(); foreach($lang as $ln) { $standard[] = $_POST['standard_'.$ln['lang']]; print_r($_POST['standard_'.$ln['lang']]); } Set_Menu_Standard(); } ?> <form action="<?php echo basename($_SERVER['PHP_SELF']); ?>" method="post"> <?...?> <?php $listmenu = List_Option_Menu(); foreach($listmenu as $menu) { if($selectedlang != $menu['lang']) { $selectedlang = $menu['lang']; echo $menu['language'] .':<br>'; } if ($menu['static'] == true) { $radiochecked = ' checked'; } else { $radiochecked = '';} echo $menu['id'].' <input type="checkbox" name="selectbox[]" value="'.$menu['id'] .'">'."\r"; echo '<input type="radio" name="standard_'.$menu['lang'].'[]" value="'.$menu['id'] .'" title="Use this option"' .$radiochecked .'><a href="#">'.$menu['title'].'</a><br>'."\r"; } ?> <input type="submit" name="usemenu" value="Spara"> </form> Quote Link to comment https://forums.phpfreaks.com/topic/85975-set-several-input-radio-buttons-as-standard/ Share on other sites More sharing options...
tinker Posted January 14, 2008 Share Posted January 14, 2008 it's like searching for black holes, you can only tell by knowing what's missing! Quote Link to comment https://forums.phpfreaks.com/topic/85975-set-several-input-radio-buttons-as-standard/#findComment-439029 Share on other sites More sharing options...
theWheeler Posted January 14, 2008 Author Share Posted January 14, 2008 it's like searching for black holes, you can only tell by knowing what's missing! Apparently something is missing I just don´t know what... Is it the array $standard or the foreach-loop...? The table in the database doesn´t update the cell with the new value... I know that the connection is working because I can insert or update other values in the same table and others... This is very strange. The $standard in the function contains: Array ( [0] => Array ( [0] => 1 ) [1] => Array ( [0] => 2 ) [2] => Array ( [0] => 4 ) ) Quote Link to comment https://forums.phpfreaks.com/topic/85975-set-several-input-radio-buttons-as-standard/#findComment-439195 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.