简体   繁体   English

无法将PHP嵌入CSS样式的单选按钮中以填充表单

[英]Trouble embedding PHP within CSS styled radio buttons to populate a form

I'm currently writing a program that allows information in a database to be edited by populating a web form. 我当前正在编写一个程序,该程序允许通过填充Web表单来编辑数据库中的信息。

However, the web page is formatted with customized radio buttons and I seem to be having trouble embedding PHP inside the HTML tags. 但是,该网页使用自定义的单选按钮设置了格式,并且似乎无法将PHP嵌入HTML标记中。 My understanding is that combinations of CSS and HTML don't allow PHP to written inside. 我的理解是CSS和HTML的组合不允许PHP内写。 Is that the problem here? 这是问题吗? (The document is saved as a PHP file) (文档另存为PHP文件)

 <div id="radio4">
     <div class="radio1" >  
         <input id="mgender" type="radio" name="GENDER" value="m" <?php echo ($GENDER == 'm') ?  "checked" : "" ;  ?>> 
             <label for="mgender"></label></div></div>

 <div id="radio5">       
     <div class="radio2">  
         <input id="fgender" type="radio" name="GENDER" value="f" <?php echo ($GENDER  == 'f') ? "checked" : "" ; ?>>
             <label for="fgender"></label></div></div>

If so, how can I fix it? 如果是这样,我该如何解决?

try with this regular expression : 试试这个正则表达式:

<div id="radio4">
     <div class="radio1" >  
         <input id="mgender" type="radio" name="GENDER" value="m" <?php if($GENDER=='m'){echo"checked";}?> /> 
             <label for="mgender">Male</label></div></div>

 <div id="radio5">       
     <div class="radio2">  
         <input id="fgender" type="radio" name="GENDER" value="f" <?php if($GENDER=='f'){echo"checked";}?> />
             <label for="fgender">Female</label></div></div>

I still haven't been able to figure this out. 我仍然无法弄清楚这一点。 I thought writing it the above way worked, but it was just automatically checking one of the radio buttons. 我以为可以用上面的方式编写它,但是它只是自动检查其中一个单选按钮。

I think it may be a configuration issue associated with my Apache server, or something in the php.ini files. 我认为这可能是与我的Apache服务器相关的配置问题,或者是php.ini文件中的某些问题。 Anyone have any knowledge of this? 有人对此有任何了解吗?

In my text editor the close tag at the end of the php statement stops being read as code. 在我的文本编辑器中,php语句末尾的close标记停止以代码形式读取。

So, for example in this statement: 因此,例如以下语句:

 <input id="mgender" type="radio" name="GENDER" value="m" <?php echo ($GENDER == 'f') ? checked="checked" : "" ; ?> [nothing read after this point] />

*edited to add code. *已编辑以添加代码。

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

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