aebstract Posted September 19, 2008 Share Posted September 19, 2008 $content .= "<form action=\"/prices/addmaterial/$var2/\" method=\"post\">"; /* ------------------------- GENERATE GRADES OF MATERIAL ------------------------- */ $result = mysql_query("SELECT DISTINCT grade FROM `materials` WHERE material='$dropdown'") or DIE(mysql_error()); while($r = mysql_fetch_array($result)) { $id_p = $r['id']; $grade = $r['grade']; $content .= "$grade<input type=\"radio\" name=\"grade\" value=\"$grade\" />"; $content .= '<select name="$grade"><option value="">----------</option>'; /* ------------------------- GENERATE SIZES OF MATERIAL ------------------------- */ $result2 = mysql_query("SELECT * FROM `materials` WHERE material='$dropdown' && grade='$grade' ORDER BY `size_d` ASC") or DIE(mysql_error()); while($r2 = mysql_fetch_array($result2)) { $id_p = $r2['id']; $size = $r2['size']; $content .= "<option value=\"{$id_p}\">{$size}\"</option>\n"; } $content .= '</select><br />'; } $content .= "Length: <input type=\"text\" size=\"5\" name=\"length\" value=\"\" /><br /> <input type=\"submit\" name=\"submit2\" value=\"Add Material\" /> "; $content .= '</form>'; Okay, time for the fun of explaining this stuff. I'm going to use two pieces of material for my example, two pieces of bearing stock. One is 303 stainless and the other is 304 stainless. In the database I have a table with this information: id - material - size - price - size_d - grade The grade is the 303 and 304, I am generating a unique radio button for each type of grade, so in this situation there are two radio buttons. Beside the radios I need to generate a drop down menu with the sizes for all the specific material of that grade. The code I posted does this fine, what I am stuck on is when I choose the first radio button that is generated and choose a size in the drop down and hit submit, I can display my grade choice but not my size choice. If I choose the last radio and a size, it'll show both. I'm sure it has something to do with how I am naming the drop down menus but I am not too sure of what to do at this point. I will keep working on it and keep this post updated. Thanks Link to comment https://forums.phpfreaks.com/topic/124928-solved-generating-dropdowns-beside-radios-dependant-on-that-radio/ Share on other sites More sharing options...
aebstract Posted September 19, 2008 Author Share Posted September 19, 2008 *bump* I've tried like 5-6 different methods this morning so far and will continue to push to try and get it to work until I get a response leading in a better direction. Link to comment https://forums.phpfreaks.com/topic/124928-solved-generating-dropdowns-beside-radios-dependant-on-that-radio/#findComment-645540 Share on other sites More sharing options...
discomatt Posted September 19, 2008 Share Posted September 19, 2008 Why not simply use $size = $_POST[ $_POST['grade'] ]; If this doesn't work, please give us an array dump of your POST arrays after submitting the page ( print_r($_POST) ) Link to comment https://forums.phpfreaks.com/topic/124928-solved-generating-dropdowns-beside-radios-dependant-on-that-radio/#findComment-645550 Share on other sites More sharing options...
aebstract Posted September 19, 2008 Author Share Posted September 19, 2008 I've tried something similar, I set $_POST['grade'] to a variable and tried to echo out $_POST['$var'] or w/e. Results for the print_r: print_r(Array) Link to comment https://forums.phpfreaks.com/topic/124928-solved-generating-dropdowns-beside-radios-dependant-on-that-radio/#findComment-645556 Share on other sites More sharing options...
aebstract Posted September 19, 2008 Author Share Posted September 19, 2008 Eh, I don't know why that is what it was showing before, but now I get this: Array ( [grade] => 303 SS [303_SS] => 1 [304_SS] => [length] => [submit2] => Add Material ) It's putting an underscore in my drop down name 'grade', is that the problem? Is there anyway for me to prevent that? Link to comment https://forums.phpfreaks.com/topic/124928-solved-generating-dropdowns-beside-radios-dependant-on-that-radio/#findComment-645557 Share on other sites More sharing options...
discomatt Posted September 19, 2008 Share Posted September 19, 2008 No, but you can accommodate to it... $size = $_POST[ str_replace(' ','_',$_POST['grade']) ]; Link to comment https://forums.phpfreaks.com/topic/124928-solved-generating-dropdowns-beside-radios-dependant-on-that-radio/#findComment-645565 Share on other sites More sharing options...
aebstract Posted September 19, 2008 Author Share Posted September 19, 2008 gotcha, thanks for the help and now I know how to check out my POST results in the future Link to comment https://forums.phpfreaks.com/topic/124928-solved-generating-dropdowns-beside-radios-dependant-on-that-radio/#findComment-645567 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.