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/

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

报告相同问题?

悬赏问题

  • ¥15 相敏解调 matlab
  • ¥15 求lingo代码和思路
  • ¥15 公交车和无人机协同运输
  • ¥15 stm32代码移植没反应
  • ¥15 matlab基于pde算法图像修复,为什么只能对示例图像有效
  • ¥100 连续两帧图像高速减法
  • ¥15 如何绘制动力学系统的相图
  • ¥15 对接wps接口实现获取元数据
  • ¥20 给自己本科IT专业毕业的妹m找个实习工作
  • ¥15 用友U8:向一个无法连接的网络尝试了一个套接字操作,如何解决?