duanjurong1347 2015-12-02 17:10
浏览 53
已采纳

为每个SQL结果行创建一个唯一的单选按钮

I would like to create a radio button that will have a unique roomCode as a selecter based on each row. So if the roomCode = 1, the unique identifier within that row will be 1. This is so I can then submit a radio button to bring up a timetable based upon the roomCode selected.

Here is my PHP code:

$numeroOption = $_POST['numero'];
$roomtype = $_POST['roomtype'];
$selectOption = $_POST['parkname'];
$query = "SELECT * FROM `ROOMS` WHERE `Capacity` < '$numeroOption' AND `Park` LIKE '$selectOption%' AND `dataProjector` LIKE '$proj_check%' AND `Whiteboard` LIKE '$white_check%' AND `OHP` LIKE '$ohp_check%' AND `WheelchairAccess` LIKE '$wheel_check%' AND `lectureCapture` LIKE '$cap_check%' AND `Style` LIKE '$roomtype%'"; 
$result = mysql_query($query);

if ($result == FALSE) 
    die ("could not execute statement $query<br />");

echo "<table>"; 
while($row = mysql_fetch_array($result))
{   
    echo "<tr><td>" . $row['roomCode'] . "</td><td>" . $row['Park'] . "</td><td>" . $row['Capacity'] . "</td><td>" . $row['Style'] . "</td><td>" . $row['dataProjector'] . "</td><td>" . $row['Whiteboard'] . "</td><td>" . $row['OHP'] . "</td><td>" . $row['wheelchairAccess'] . "</td><td>" . $row['lectureCapture'] . "</td></tr>";
}
echo "</table>"; 
mysql_close(); 
}
  • 写回答

1条回答 默认 最新

  • douhuan1950 2015-12-02 17:48
    关注

    For starters, you should be using mysqli or PDO. PDO is best if you will be using multiple databases (mysql and sql, etc) but if not, I prefer mysqli because i feel its more efficient.

    To solve your problem...

        <form>
          while($row = mysql_fetch_array($result))
          { 
              echo "<tr><td><input type="radio" name="radioSelect" value= "" checked="" /></td><td>" . $row['roomCode'] . "</td><td>" . $row['Park'] . "</td><td>" . $row['Capacity'] . "</td><td>" . $row['Style'] . "</td><td>" . $row['dataProjector'] . "</td><td>" . $row['Whiteboard'] . "</td><td>" . $row['OHP'] . "</td><td>" . $row['wheelchairAccess'] . "</td><td>" . $row['lectureCapture'] . "</td></tr>";
        }
         }
        <input type="submit"/>
        </form>
    
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥20 完全没有学习过GAN,看了CSDN的一篇文章,里面有代码但是完全不知道如何操作
  • ¥15 使用ue5插件narrative时如何切换关卡也保存叙事任务记录
  • ¥20 软件测试决策法疑问求解答
  • ¥15 win11 23H2删除推荐的项目,支持注册表等
  • ¥15 matlab 用yalmip搭建模型,cplex求解,线性化处理的方法
  • ¥15 qt6.6.3 基于百度云的语音识别 不会改
  • ¥15 关于#目标检测#的问题:大概就是类似后台自动检测某下架商品的库存,在他监测到该商品上架并且可以购买的瞬间点击立即购买下单
  • ¥15 神经网络怎么把隐含层变量融合到损失函数中?
  • ¥15 lingo18勾选global solver求解使用的算法
  • ¥15 全部备份安卓app数据包括密码,可以复制到另一手机上运行