简体   繁体   English

在召回时在列表框中显示储值表单列表框

[英]Show stored value form listbox in listbox on recall

I have a listbox with a few values ("a","b","c"). 我有一个带有一些值的列表框(“ a”,“ b”,“ c”)。 eg. 例如。 the user selects "b" which is then stored in MySQL dbase. 用户选择“ b”,然后将其存储在MySQL dbase中。 When the user recalls this website with the listbox i'd like it to show "b" as first value in the listbox. 当用户使用列表框调用此网站时,我希望它在列表框中显示“ b”作为第一个值。 (or at least show it as its previous choice) (或至少将其显示为以前的选择)

So the result needs to show up in a listbox.. not as plain text... with along the other available choices... 因此结果需要显示在列表框中..而不是纯文本...以及其他可用选项...

How do i do that? 我怎么做?

(all in mysql, php) (全部在mysql,php中)

There's a few ways, but my best offer is that you generate a random value for when you write your data to database, store it along with the users choice and also create a cookie with the random variable in it ( setting cookies in PHP ). 有几种方法,但最好的办法是,在将数据写入数据库时​​生成一个随机值,将其与用户选择一起存储,还创建一个包含随机变量的cookie(在PHP中设置cookie )。 Then every time a user comes to your page you check if they have that cookie and the value inside of it. 然后,每次用户访问您的页面时,您都会检查他们是否具有该cookie及其值。 Then you can fetch the stored choice based on that value from database. 然后,您可以基于该值从数据库中获取存储的选择。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM