And any suggestions as to doing this better are greatly appreciated...!!!
The user is presented with a form containing 3 select lists.
Each list has associated with it a submit button.
The user selects from one list, clicks and the switch-case block should determine the item selected based on which submit is posted.
The funky behavior is: when I print_r(), I can see which select is chosen, however, the switch-case block code doesn't execute.
Results of clicking first submit:
Code: Select all
Array
(
їitemName] => Array
(
ї0] => id3d5293043:Cheesecake
ї1] => id3d4bd781c:Jalapeno Poppers
ї2] => id3cf3fc332:test soup
)
їsubmit] => Array
(
їshowItem] => Array
(
ї0] => Show Item
)
)
)Code: Select all
switch ( $_POSTї'submit']ї'showItem'])
{
case $_POSTї'submit']ї'showItem']ї0]:
$code = explode(':', $_POSTї'itemName']ї0]);
$recCode = $codeї0];
echo $recCode;
break;
case $_POSTї'submit']ї'showItem']ї1]:
$code = explode(":", $_POSTї'itemName']ї1]);
$recCode = $codeї0];
echo $recCode;
break;
case $_POSTї'submit']ї'showItem']ї2]:
$code = explode(":", $_POSTї'itemName']ї2]);
$recCode = $codeї0];
echo $recCode;
break;
}
include("../../include/functions/functions.inc");
include("../../include/phpClasses/MyConnect.php");
new MyConnect();
$box = array();
$query = "SELECT item_name, rec_code FROM menu_item WHERE item_name BETWEEN 'A' AND 'G' ";
$arr = getQueryResults( $query );
$boxї] = createDropDownBox2("itemNameї]", $arr);
$query = "SELECT item_name, rec_code FROM menu_item WHERE item_name BETWEEN 'H' AND 'P' ";
$arr = getQueryResults( $query );
$boxї] = createDropDownBox2("itemNameї]", $arr);
$query = "SELECT item_name, rec_code FROM menu_item WHERE item_name BETWEEN 'Q' AND 'Z' ";
$arr = getQueryResults( $query );
$boxї] = createDropDownBox2("itemNameї]", $arr);
?>
<form action="<?php echo $_SERVERї'PHP_SELF'] ?>" method="post" name="frmMenuItemSelect" id="frmMenuItemSelect">
<table align="left" bgcolor="#FCECB6" cellpadding="2" cellspacing="2">
<th align="center" colspan="3">Select Menu Item</th>
<tr>
<td><font color="blue" size="+1">A - G</font></td>
<td><?php echo $boxї0] ?></td>
<td><input type="submit" name="submitїshowItem]ї0]" value="Show Item"></td>
</tr>
<tr>
<td><font color="blue" size="+1">H - P</font></td>
<td><?php echo $boxї1] ?></td>
<td><input type="submit" name="submitїshowItem]ї1]" value="Show Item"></td>
</tr>
<tr>
<td><font color="blue" size="+1">Q - Z</font></td>
<td><?php echo $boxї2] ?></td>
<td><input type="submit" name="submitїshowItem]ї2]" value="Show Item"></td>
</tr>
<tr>
<td align="center"></td>
<td><font color="red" size="+1">Make only 1 Choice!!</font></td>
<td></td>
</tr>
</table>
</form>Code: Select all
function createDropDownBox2($name,$ar)
{
$len = sizeof($ar);
$tags = "<SELECT name='" . $name . "'>\n";
for($i=0; $i<$len; $i++)
{
$tags .= "<OPTION value='" .$arї$i]ї1] .":" . $arї$i]ї0] . "'>" . $arї$i]ї0] . "</OPTION>\n" ;
}
$tags .= "</SELECT>";
return $tags;
}