Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/php/294.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Php 单选按钮发布_Php_Mysql_Sql_Radio Button - Fatal编程技术网

Php 单选按钮发布

Php 单选按钮发布,php,mysql,sql,radio-button,Php,Mysql,Sql,Radio Button,这就是问题所在。我正在运行一个mysql查询,并使用while语句将该查询的结果放入单选按钮中。单选按钮的数量可能会有所不同,因此我无法使用POST功能设置单选按钮的数量。我正在努力使用它,以便用户可以选择其中一行,然后将查询中的“serverId”数据传递到test.php页面。任何帮助都将不胜感激。谢谢 <html> <head> <title>Server Information</title> </head> <

这就是问题所在。我正在运行一个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>  

服务器信息

好的,有几个建议

首先,对于无线电输入,从值标记中删除“服务器信息”,并粘贴到serverID echo中。比如说

<input type="radio" name="server" value="<?php echo $row['serverId']; ?>" />

这只会使它显示字段中的单选按钮,但由于php命令周围的引号,它不再显示记录,只显示空白。任何想法。你能在浏览器中查看页面源代码并粘贴它生成的代码吗?(也许更新你上面的问题)我错了。我道歉。它实际上是在serverid字段中显示单选按钮,并将数据从serverid推送到下一个字段。但它现在确实工作得很好,只是它没有在与单选按钮相同的字段中显示serverid……好吧,那听起来很简单。只需将
单元格中的数据重新排列到正确的位置即可。谢谢。都整理好了。