简体   繁体   English

粘性选择php。 其他堆栈溢出答案对我不起作用

[英]Sticky select php. Other Stack Overflow answer doesn't work for me

So I tried going with the answer from Sticky Select Option which ended up looking like this 因此,我尝试使用“ 粘性选择选项”的答案,最终看起来像这样

<option value="2" <?php if(isset($yourDilution && $yourDilution == 2)){ echo 'selected = "selected" '; }?>>1:1</option>

and that breaks my code and gives me a syntax error. 这破坏了我的代码,并给了我一个语法错误。 Alternatively I have 或者我有

<option value="3" <?php if($yourDilution == 3) echo 'selected="selected"'; ?>>1:2</option>

and that gives me the problem I had before coming here to look at other answers on the topic. 这给了我一个问题,在我来这里查看有关该主题的其他答案之前。 The problem is that the drop down gets filled with Notice: Undefined variable $yourDilution etc. Thanks for taking a minute to point me in the right direction. 问题是下拉列表中充满了注意:未定义的变量$ yourDilution等。感谢您抽出一点时间向我指出正确的方向。

if(isset($yourDilution && $yourDilution == 2))

应该

if(isset($yourDilution) && $yourDilution == 2)

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

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