【发布时间】:2014-05-10 05:38:42
【问题描述】:
这就是问题所在。我正在运行一个 mysql 查询,并将该查询的结果放入带有 while 语句的单选按钮中。单选按钮的数量可能会有所不同,因此我无法使用 POST 功能来设置它们的数量。我正在努力使用户可以选择其中一行,然后将查询中的“serverId”数据传递到 test.php 页面。任何帮助将不胜感激。谢谢。
<html>
<head>
<title>Server Information</title>
</head>
<body>
<?php
//Starts the session and grabs the username from it
session_start();
$name=mysql_real_escape_string($_SESSION['username']);
include 'header.php';
include 'mysql_connect.php';
mysql_select_db('ist421test');
$result = mysql_query("SELECT userName, dateCreated, serverName, serverId, publicDNS, isRunning FROM server_tbl WHERE userName='$name' ORDER BY dateCreated DESC") or die(mysql_error());
if(mysql_num_rows($result) > 0): ?>
<form method="post" name="server_information" id="server_information" action="test.php">
<label>Server Information</label><br><br>
<table border='1'>
<tr>
<th>Selection</th>
<th>User Name</th>
<th>Date Created</th>
<th>Server Name</th>
<th>Server Id</th>
<th>Public DNS</th>
<th>Running</th>
</tr>
<?php while($row = mysql_fetch_assoc($result)): ?>
<tr>
<td><input method="post" type="radio" name="server" value="server_information" action="test.php"></td>
<td><?php echo $row['userName']; ?></td>
<td><?php echo $row['dateCreated']; ?></td>
<td><?php echo $row['serverName']; ?></td>
<td><?php echo $row['serverId']; ?></td>
<td><?php echo $row['publicDNS'] ?></td>
<td><?php echo $row['isRunning']; ?></td>
</tr>
<?php endwhile; ?>
</table>
<input type="submit" name="server_stop" value="Stop Server"/>
<input type="submit" name="server_terminate" value="Terminate Server"/>
</form>
<?php endif; ?>
</body>
</html>
【问题讨论】:
标签: php mysql sql radio-button