bsamson Posted March 17, 2007 Share Posted March 17, 2007 Alright. I have a form on let's say, page 1 and the form contains a dropdown with numbers as values. IE: <select size="1" name="store"> <option value="1">Auburn</option> <option value="2">Camillus</option> <option value="3">Canandaigua</option> <option value="4">Colonie</option> <option value="5">Cortland</option> <option value="6">Great Northern</option> <option value="7">Liverpool</option> <option value="8">New Hartford</option> <option value="10">Oneonta</option> <option value="12">Shoppingtown</option> <option value="13">Vestal</option> <option value="14">Watertown</option> </select> Now, the form get's directed to page 2 and I have this code: switch ($_POST[store]) { case 1: $stadr = "1234 duffy ave"; $cszip = "New York, NY"; $phnum = "111-222-3333"; case 2: $stadr = "1234 duffy ave"; $cszip = "New York, NY"; $phnum = "111-222-3333"; case 3: $stadr = "1234 duffy ave"; $cszip = "New York, NY"; $phnum = "111-222-3333"; case 5: $stadr = "1234 duffy ave"; $cszip = "New York, NY"; $phnum = "111-222-3333"; case 6: $stadr = "1234 duffy ave"; $cszip = "New York, NY"; $phnum = "111-222-3333"; case 7: $stadr = "1234 duffy ave"; $cszip = "New York, NY"; $phnum = "111-222-3333"; case 8: $stadr = "1234 duffy ave"; $cszip = "New York, NY"; $phnum = "111-222-3333"; case 10: $stadr = "1234 duffy ave"; $cszip = "New York, NY"; $phnum = "111-222-3333"; case 12: $stadr = "1234 duffy ave"; $cszip = "New York, NY"; $phnum = "111-222-3333"; case 13: $stadr = "1234 duffy ave"; $cszip = "New York, NY"; $phnum = "111-222-3333"; case 14: $stadr = "1234 duffy ave"; $cszip = "New York, NY"; $phnum = "111-222-3333"; } PLEASE NOTE that each case has a different address I just changed it for the sake of posting it here. Now, when I run through page 1 and hit submit it always displays case 14's variables. So, I went and I put an echo statement at the top (ie: echo $_POST[store]; ) and it returns the proper values. I just cannot figure out why It' not working. Please, any advice would be very much appreciated! Thanks. Link to comment https://forums.phpfreaks.com/topic/43120-solved-issues-with-switch/ Share on other sites More sharing options...
toplay Posted March 17, 2007 Share Posted March 17, 2007 You simply forgot the break; in each case: see the manual page: http://us2.php.net/switch Link to comment https://forums.phpfreaks.com/topic/43120-solved-issues-with-switch/#findComment-209408 Share on other sites More sharing options...
shaunrigby Posted March 17, 2007 Share Posted March 17, 2007 switch ($_POST[store]) { case 1: $stadr = "1234 duffy ave"; $cszip = "New York, NY"; $phnum = "111-222-3333"; break; case 2: $stadr = "1234 duffy ave"; $cszip = "New York, NY"; $phnum = "111-222-3333"; break; //etc } Link to comment https://forums.phpfreaks.com/topic/43120-solved-issues-with-switch/#findComment-209430 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.