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>
    
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

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