Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/php/297.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 如何选择表中的两列或多列并通过GET/POST发送?_Php_Html_Mysql_Radio Button_Html Table - Fatal编程技术网

Php 如何选择表中的两列或多列并通过GET/POST发送?

Php 如何选择表中的两列或多列并通过GET/POST发送?,php,html,mysql,radio-button,html-table,Php,Html,Mysql,Radio Button,Html Table,我有一个使用Mysql和PHP生成的简单HTML表 我想选择表格中的一行,并通过GET或POST将两个或更多的内容发送到另一页,尽可能使用简单的方式 今天,我只能使用如下“单选”按钮发送一个参数: <form method="GET" action="table.php"> <table> <?php $query="SELECT * from prices ORDER BY region limit 10"; $result=mysql_query($query,

我有一个使用Mysql和PHP生成的简单HTML表

我想选择表格中的一行,并通过GET或POST将两个或更多的内容发送到另一页,尽可能使用简单的方式

今天,我只能使用如下“单选”按钮发送一个参数:

<form method="GET" action="table.php">
<table>
<?php
$query="SELECT * from prices ORDER BY region limit 10";
$result=mysql_query($query,$connection);
while ($linha = mysql_fetch_array($result)) {
?>
<tbody>
    <tr>
     <td><input type="radio" name="region"  value="<?php echo $linha['region'] ?>" /></td>
     <td><?php echo $row['type']; ?></td>
     <td><?php echo $row['region']; ?></td>
     <td><?php echo $row['platform']; ?></td>  
     <td><?php echo $row['price']; ?></td>                                      
    </tr>
</tbody>

<?php
}
?>

</table>
<input type="submit" value="Submit"/>       
</form>
<?php
   foreach($_GET['type'] as types)
    {
      echo types;
    }
?>
例如,我如何获得:

tabela.php?region=ap-northeast-1&type=c1.medium
==编辑:

我的桌子就是这样的:

type    region  platform    price $/h
m3.xlarge   ap-northeast-1  windows 0.980
hs1.8xlarge ap-northeast-1  rhel    5.810
hi1.4xlarge ap-northeast-1  rhel    3.960
m1.medium   ap-northeast-1  windows 0.230
cg1.4xlarge ap-northeast-1  rhel    4.450
cc2.8xlarge ap-northeast-1  rhel    3.100
c1.xlarge   ap-northeast-1  rhel    0.855
c1.medium   ap-northeast-1  rhel    0.254
m2.4xlarge  ap-northeast-1  rhel    2.135
m2.2xlarge  ap-northeast-1  rhel    1.079

我希望能够将值“type”“platform”发送到另一个页面:)

您可以使用隐藏字段作为type

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

您可以对类型使用隐藏字段

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

您可以对类型使用隐藏字段

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

您可以对类型使用隐藏字段

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

您可以使用输入类型
隐藏
执行此操作:

<td><input type="hidden" name="type" value="<?php echo $row['type']; ?>"><?php echo $row['type']; ?></td>

要获取单选按钮的值,只需在table.php中使用
$\u get['region']

您可以使用input type
hidden
执行此操作:

<td><input type="hidden" name="type" value="<?php echo $row['type']; ?>"><?php echo $row['type']; ?></td>

要获取单选按钮的值,只需在table.php中使用
$\u get['region']

您可以使用input type
hidden
执行此操作:

<td><input type="hidden" name="type" value="<?php echo $row['type']; ?>"><?php echo $row['type']; ?></td>

要获取单选按钮的值,只需在table.php中使用
$\u get['region']

您可以使用input type
hidden
执行此操作:

<td><input type="hidden" name="type" value="<?php echo $row['type']; ?>"><?php echo $row['type']; ?></td>
要获取单选按钮的值,只需在table.php中使用
$\u get['region']

我有三个想法:

您可以使用jQuery(javascript)来实现这一点


类型
区域
平台
价格
美元/小时
m3.xlarge
ap-东北-1
窗户
0.980
jQuery(文档).ready(函数(){
jQuery('.RegionElectradio')。单击(函数(){
jQuery('#platform').attr('value',jQuery(this.parent().children().eq(3.html());
});
});
您可以为每个记录使用单独的表单:

<form method="get" action="table.php">

<table>
<tr>
    <td>type</td>
    <td>region</td>
    <td>platform</td>
    <td>price</td>
    <td>$/h</td>
</tr>
<tr>
    <td><input type="submit" value="Select"/> <input type="hidden" name="region"  value="m3.xlarge" />
    <input type="hidden" name="platform" value="windows" />
    </td>
    <td>m3.xlarge</td>
    <td>ap-northeast-1</td>
    <td>windows</td>
    <td>0.980</td>
</tr>
</table>
</form>

<form method="get" action="table.php">

<table>
<tr>
    <td>type</td>
    <td>region</td>
    <td>platform</td>
    <td>price</td>
    <td>$/h</td>
</tr>
<tr>
    <td><input type="submit" value="Select"/> <input type="hidden" name="region"  value="m3.xlarge" />
    <input type="hidden" name="platform" value="windows" />
    </td>
    <td>m3.small</td>
    <td>ap-southeast-1</td>
    <td>unix</td>
    <td>0.980</td>
</tr>
</table>
</form>

类型
区域
平台
价格
美元/小时
m3.xlarge
ap-东北-1
窗户
0.980
类型
区域
平台
价格
美元/小时
m3.小型
ap-东南-1
unix
0.980
您还可以将这两个值放在同一个选项输入中,然后在php中拆分:

<form method="get" action="table.php">

<table>
<tr>
    <td>type</td>
    <td>region</td>
    <td>platform</td>
    <td>price</td>
    <td>$/h</td>
</tr>
<tr>
    <td><input type="radio" class="regionSelectRadio" name="region"  value="m3.xlarge;windows" />
    </td>
    <td>m3.xlarge</td>
    <td>ap-northeast-1</td>
    <td>windows</td>
    <td>0.980</td>
</tr>
<tr>
    <td>type</td>
    <td>region</td>
    <td>platform</td>
    <td>price</td>
    <td>$/h</td>
</tr>
<tr>
    <td><input type="radio" class="regionSelectRadio" name="region"  value="m3.small;unix" />
    </td>
    <td>m3.small</td>
    <td>ap-southeast-1</td>
    <td>unix</td>
    <td>0.980</td>
</tr>
</table>
</form>

<?php
$values = explode(';',$_REQUEST['region'])
?>

类型
区域
平台
价格
美元/小时
m3.xlarge
ap-东北-1
窗户
0.980
类型
区域
平台
价格
美元/小时
m3.小型
ap-东南-1
unix
0.980
我有三个想法:

您可以使用jQuery(javascript)来实现这一点


类型
区域
平台
价格
美元/小时
m3.xlarge
ap-东北-1
窗户
0.980
jQuery(文档).ready(函数(){
jQuery('.RegionElectradio')。单击(函数(){
jQuery('#platform').attr('value',jQuery(this.parent().children().eq(3.html());
});
});
您可以为每个记录使用单独的表单:

<form method="get" action="table.php">

<table>
<tr>
    <td>type</td>
    <td>region</td>
    <td>platform</td>
    <td>price</td>
    <td>$/h</td>
</tr>
<tr>
    <td><input type="submit" value="Select"/> <input type="hidden" name="region"  value="m3.xlarge" />
    <input type="hidden" name="platform" value="windows" />
    </td>
    <td>m3.xlarge</td>
    <td>ap-northeast-1</td>
    <td>windows</td>
    <td>0.980</td>
</tr>
</table>
</form>

<form method="get" action="table.php">

<table>
<tr>
    <td>type</td>
    <td>region</td>
    <td>platform</td>
    <td>price</td>
    <td>$/h</td>
</tr>
<tr>
    <td><input type="submit" value="Select"/> <input type="hidden" name="region"  value="m3.xlarge" />
    <input type="hidden" name="platform" value="windows" />
    </td>
    <td>m3.small</td>
    <td>ap-southeast-1</td>
    <td>unix</td>
    <td>0.980</td>
</tr>
</table>
</form>

类型
区域
平台
价格
美元/小时
m3.xlarge
ap-东北-1
窗户
0.980
类型
区域
平台
价格
美元/小时
m3.小型
ap-东南-1
unix
0.980
您还可以将这两个值放在同一个选项输入中,然后在php中拆分:

<form method="get" action="table.php">

<table>
<tr>
    <td>type</td>
    <td>region</td>
    <td>platform</td>
    <td>price</td>
    <td>$/h</td>
</tr>
<tr>
    <td><input type="radio" class="regionSelectRadio" name="region"  value="m3.xlarge;windows" />
    </td>
    <td>m3.xlarge</td>
    <td>ap-northeast-1</td>
    <td>windows</td>
    <td>0.980</td>
</tr>
<tr>
    <td>type</td>
    <td>region</td>
    <td>platform</td>
    <td>price</td>
    <td>$/h</td>
</tr>
<tr>
    <td><input type="radio" class="regionSelectRadio" name="region"  value="m3.small;unix" />
    </td>
    <td>m3.small</td>
    <td>ap-southeast-1</td>
    <td>unix</td>
    <td>0.980</td>
</tr>
</table>
</form>

<?php
$values = explode(';',$_REQUEST['region'])
?>

类型
区域
平台
价格
美元/小时
m3.xlarge
ap-东北-1
窗户
0.980
类型
区域
平台
价格
美元/小时
m3.小型
ap-东南-1
unix
0.980
我有三个想法:

您可以使用jQuery(javascript)来实现这一点


类型
区域
平台
价格
美元/小时
m3.xlarge
ap-东北-1
窗户
0.980
jQuery(文档).ready(函数(){
jQuery('.RegionElectradio')。单击(函数(){
jQuery('#platform').attr('value',jQuery(this.parent().children().eq(3.html());
});
});
您可以为每个记录使用单独的表单:

<form method="get" action="table.php">

<table>
<tr>
    <td>type</td>
    <td>region</td>
    <td>platform</td>
    <td>price</td>
    <td>$/h</td>
</tr>
<tr>
    <td><input type="submit" value="Select"/> <input type="hidden" name="region"  value="m3.xlarge" />
    <input type="hidden" name="platform" value="windows" />
    </td>
    <td>m3.xlarge</td>
    <td>ap-northeast-1</td>
    <td>windows</td>
    <td>0.980</td>
</tr>
</table>
</form>

<form method="get" action="table.php">

<table>
<tr>
    <td>type</td>
    <td>region</td>
    <td>platform</td>
    <td>price</td>
    <td>$/h</td>
</tr>
<tr>
    <td><input type="submit" value="Select"/> <input type="hidden" name="region"  value="m3.xlarge" />
    <input type="hidden" name="platform" value="windows" />
    </td>
    <td>m3.small</td>
    <td>ap-southeast-1</td>
    <td>unix</td>
    <td>0.980</td>
</tr>
</table>
</form>

类型
区域
平台
价格
美元/小时
m3.xlarge
ap-东北-1
窗户
0.980
类型
区域
平台
价格
美元/小时
m3.小型
ap-东南-1
unix
0.980
您还可以将这两个值放在同一个选项输入中,然后在php中拆分:

<form method="get" action="table.php">

<table>
<tr>
    <td>type</td>
    <td>region</td>
    <td>platform</td>
    <td>price</td>
    <td>$/h</td>
</tr>
<tr>
    <td><input type="radio" class="regionSelectRadio" name="region"  value="m3.xlarge;windows" />
    </td>
    <td>m3.xlarge</td>
    <td>ap-northeast-1</td>
    <td>windows</td>
    <td>0.980</td>
</tr>
<tr>
    <td>type</td>
    <td>region</td>
    <td>platform</td>
    <td>price</td>
    <td>$/h</td>
</tr>
<tr>
    <td><input type="radio" class="regionSelectRadio" name="region"  value="m3.small;unix" />
    </td>
    <td>m3.small</td>
    <td>ap-southeast-1</td>
    <td>unix</td>
    <td>0.980</td>
</tr>
</table>
</form>

<?php
$values = explode(';',$_REQUEST['region'])
?>

类型
区域
平台
价格
美元/小时
m3.xlarge
ap-东北-1
窗户
0.980
类型
区域
平台
价格
美元/小时
m3.小型
ap-东南-1
unix
0.980
我有三个想法:

您可以使用jQuery(javascript)来实现这一点


类型
区域
平台
价格
美元/小时
m3.xlarge
ap-东北-1
窗户
0.980
jQuery(文档).ready(函数(){
jQuery('.RegionElectradio')。单击(函数(){
jQuery('#platform').attr('value',jQuery(this.parent().children().eq(3.html());
});
});
您可以为每个记录使用单独的表单:

<form method="get" action="table.php">

<table>
<tr>
    <td>type</td>
    <td>region</td>
    <td>platform</td>
    <td>price</td>
    <td>$/h</td>
</tr>
<tr>
    <td><input type="submit" value="Select"/> <input type="hidden" name="region"  value="m3.xlarge" />
    <input type="hidden" name="platform" value="windows" />
    </td>
    <td>m3.xlarge</td>
    <td>ap-northeast-1</td>
    <td>windows</td>
    <td>0.980</td>
</tr>
</table>
</form>

<form method="get" action="table.php">

<table>
<tr>
    <td>type</td>
    <td>region</td>
    <td>platform</td>
    <td>price</td>
    <td>$/h</td>
</tr>
<tr>
    <td><input type="submit" value="Select"/> <input type="hidden" name="region"  value="m3.xlarge" />
    <input type="hidden" name="platform" value="windows" />
    </td>
    <td>m3.small</td>
    <td>ap-southeast-1</td>
    <td>unix</td>
    <td>0.980</td>
</tr>
</table>
</form>

类型
区域
平台
价格
美元/小时
m3.xlarge
ap-东北-1
窗户
0.980
类型
区域
平台
价格
美元/小时
m3.小型
ap-东南-1
unix
0.980
您还可以将这两个值放在同一个选项输入中,然后在php中拆分:

<form method="get" action="table.php">

<table>
<tr>
    <td>type</td>
    <td>region</td>
    <td>platform</td>
    <td>price</td>
    <td>$/h</td>
</tr>
<tr>
    <td><input type="radio" class="regionSelectRadio" name="region"  value="m3.xlarge;windows" />
    </td>
    <td>m3.xlarge</td>
    <td>ap-northeast-1</td>
    <td>windows</td>
    <td>0.980</td>
</tr>
<tr>
    <td>type</td>
    <td>region</td>
    <td>platform</td>
    <td>price</td>
    <td>$/h</td>
</tr>
<tr>
    <td><input type="radio" class="regionSelectRadio" name="region"  value="m3.small;unix" />
    </td>
    <td>m3.small</td>
    <td>ap-southeast-1</td>
    <td>unix</td>
    <td>0.980</td>
</tr>
</table>
</form>

<?php
$values = explode(';',$_REQUEST['region'])
?>

类型
区域
平台
价格
美元/小时
m3.xlarge
ap-东北-1
窗户
0.980
类型
区域
平台
价格
美元/小时
m3.小型
ap-东南-1
unix
0.980


也将类型设置为表单字段您可以创建一个隐藏输入,每次选择收音机时,使用javascriptUse
复选框设置隐藏值,而不是使用
收音机
?@johncode您能举个例子吗?@putvande“checkbox”允许我发送多行,我想在同一行中发送两个数据:)同时将类型设置为表单字段