dongzha0813 2011-08-30 11:34
浏览 25
已采纳

如何在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 ?

  • 写回答

2条回答 默认 最新

  • doujiu6976 2011-08-30 11:41
    关注

    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

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(1条)

报告相同问题?

悬赏问题

  • ¥15 GD32 SPI通信时我从机原样返回收到的数据怎么弄?
  • ¥15 phython读取excel表格报错 ^7个 SyntaxError: invalid syntax 语句报错
  • ¥20 @microsoft/fetch-event-source 流式响应问题
  • ¥15 ogg dd trandata 报错
  • ¥15 高缺失率数据如何选择填充方式
  • ¥50 potsgresql15备份问题
  • ¥15 Mac系统vs code使用phpstudy如何配置debug来调试php
  • ¥15 目前主流的音乐软件,像网易云音乐,QQ音乐他们的前端和后台部分是用的什么技术实现的?求解!
  • ¥60 pb数据库修改与连接
  • ¥15 spss统计中二分类变量和有序变量的相关性分析可以用kendall相关分析吗?