how to properly use switch function in php -
i want use switch function on value of radio button don't know how proper use it.
if(isset($_post['itemtype'])) { $itemtype = $_post["itemtype"]; switch ($itemtype) { case "ingredient": $brandname = $_post["brandname"]; if(isset($_post['brandname'])) { $try2 = "brandname working"; } else { $errormsg = 'error on branchname'; } break; case "miscellaneous": $size = $_post["size"]; $color = $_post["color"]; if(isset($_post['size'])) { $try2 = "misc working"; } else { $errormsg = 'error on size'; break; } else { $errormsg = 'error5'; }
my bad on string part :) doesn't check if brandname set or null.
problem strings aren't inside quotes ex : case miscellaneous: should case "miscellaneous":
Comments
Post a Comment