doulao1934 2014-03-24 17:42
浏览 58
已采纳

使用php预填充HTML Radio选择

So based on if my database value is a 1 or 0 I want this enabled/disabled api settings page radio buttons to be prepopulated. Yet everything I have seen online simply is not working. Any ideas how to get this to work? Here is my snippit code on how I am doing my radio portion. Keep in mind when I select enable or disable and submit my form it does change the database value to a 1 or 0. I just can't get it to be selected when the page loads for my life :| ... Any help is appreciated! status is my variable set to a 1 or 0 by the way!

<form action="api_settings.php"  method="post">
<table width="90%" border="0" cellspacing="0" cellpadding="6">
  <tr>
    Status:<br />
    <input type="radio" name="status"  value="0" <?php if($status == 0){?> checked="checked"<?}?> />Disabled Remote Access<br />
    <input type="radio" name="status"  value="1" <?php if($status == 1){?> checked="checked"<?}?> />Enabled Remote Access<br />
  </tr>
  • 写回答

1条回答 默认 最新

  • dongyan2445 2014-03-24 17:48
    关注

    I don't believe it's a problem with the PHP, I think the problem is that you don't have a <td></td> tag within your <tr></tr>.

    Before: http://jsfiddle.net/efYZF/ After: http://jsfiddle.net/efYZF/1/

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥30 这是哪个作者做的宝宝起名网站
  • ¥60 版本过低apk如何修改可以兼容新的安卓系统
  • ¥25 由IPR导致的DRIVER_POWER_STATE_FAILURE蓝屏
  • ¥50 有数据,怎么建立模型求影响全要素生产率的因素
  • ¥50 有数据,怎么用matlab求全要素生产率
  • ¥15 TI的insta-spin例程
  • ¥15 完成下列问题完成下列问题
  • ¥15 C#算法问题, 不知道怎么处理这个数据的转换
  • ¥15 YoloV5 第三方库的版本对照问题
  • ¥15 请完成下列相关问题!