1
因此,這裏的問題。我正在運行一個mysql查詢並使用while語句將該查詢的結果投入到單選按鈕中。單選按鈕的數量可能會有所不同,所以我不能使用POST功能對它們進行一定數量的設置。我很努力的讓用戶可以選擇其中一行,然後查詢中的「serverId」數據被傳遞到test.php頁面。任何幫助將不勝感激。謝謝。單選按鈕POST問題
<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命令現在不顯示記錄只是空白。有任何想法嗎。 – h3tr1ck
你能在瀏覽器中查看頁面源代碼並粘貼它生成的代碼嗎? (也許更新你的問題上面) – Wireblue
我錯了。我道歉。它實際上在serverid字段中顯示單選按鈕,並將來自serverid的數據推送到下一個字段。但它現在的工作很好,只是它不會在同一領域的單選按鈕.... – h3tr1ck