3个带值的下拉菜单
$options1 = array( 1=>'= Equals', '≠ Does not Equal', '> Is greater than', '≥ Is greater than or equal to', '< Is less than', '≤ Is less than or equal', '∋ Contains', '∌ Does not contain');
$counter_maximum = 3;
while ($counter < $counter_maximum){
echo '
<select name="entry_id_selector[]">';
foreach ( $options1 as $i1=>$opt1 ) :
echo '<option value="' .$i1 .'"';
foreach ($entry_id_selector_topic as $entry_id_selector_i=>$entry_id_selector_topic_value ) :
echo (($i1 == $entry_id_selector_topic_value)? 'selected' : "");
endforeach;
echo '>';
echo $opt1 .'</option>';
endforeach;
echo '</select>';
$counter++;
}
用户选择了一些值
使用用户选择的值设置变量(数组)(此代码高于所有其他代码;位于页面顶部)
$entry_id_selector_topic = $_POST['entry_id_selector'];
默认值(页面首次加载后)是 $options1 或= Equals
. 用户单击提交按钮后,我想记住用户选择的值。
但是使用此代码是以下行为:
1) 如果用户仅在一个下拉菜单中更改/选择值,则单击提交后,所有下拉菜单中的值都会更改为用户选择的值。
2) 如果用户在多个下拉菜单中更改值,则所有菜单中的值都会更改/选择为值更改的最后一个下拉菜单的值。
实验时试图检查$entry_id_selector_topic_value
并在下面$entry_id_selector_topic = $_POST['entry_id_selector'];
放置此代码
foreach ($entry_id_selector_topic as $entry_id_selector_i=>$entry_id_selector_topic_value ) {
echo $entry_id_selector_topic_value .' $entry_id_selector_topic_value<br>';
}
这$entry_id_selector_topic_value
正是从每个下拉菜单中选择的值。
需要更正(更改)什么以记住用户在每个下拉菜单中选择的值?