如何在PHP的列表框中保持价值?

如何在PHP的列表框中保持价值?

问题描述:

I got a listbox in my php page that generate from another listbox, the code is as follows

<?php $myArray1 = $_POST['countryRF'];?>
                    <select name='countryRF[]' id='countryRF' size='10' multiple style='width:180px' class='selfont'>
                    <?php
                    foreach($myArray1 as $value){ // Loop through each element
                          print "<option value=\"".$value."\">".$value."</option>";
                    }
                    ?>
                    </option></select>

While refreshing the form listbox get empty, how can I keep added values even after form reload ?

Is it possible to keep the mysql result table stable even after form reloading by session ? If so please give me a help ?

我的php页面中有一个列表框,从另一个列表框生成,代码如下 p> \ n

 &lt;?php $ myArray1 = $ _POST ['countryRF'];?&gt; 
&lt; select name ='countryRF []'id ='countryRF'size ='10'倍数 style ='width:180px'class ='selfont'&gt; 
&lt;?php 
 foreach($ myArray1 as $ value){//遍历每个元素
 print“&lt; option value = \”“。  $ value。“\”&gt;“。$ value。”&lt; / option&gt;“; 
} 
?&gt; 
&lt; / option&gt;&lt; / select&gt; 
  code>  pre  > 
 
 

刷新表单列表框时,如果表单重新加载后如何保留添加值? p>

是否可以保留mysql结果表 即使在会议重新加载后仍然稳定? 如果是这样,请给我一个帮助? strong> p> div>

i see you get the 'countryRF' from post.

you can store it in a cookie/session, of store it on the server.

use

if (isset($_POST['countryRF'])) {
    $_COOKIE['countryRF'] = $_POST['countryRF'];
}
$myArray = $_COOKIE['countryRF'];

same goes with session

save them into Sessions