Jump to content

[SOLVED] Issues with SWITCH


bsamson

Recommended Posts

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

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.