Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/html/73.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

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/.net/24.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 将按钮添加到HTML表中的一行,该行带有指向URL的链接,URL包含该行中另一列的数据_Php_Html - Fatal编程技术网

Php 将按钮添加到HTML表中的一行,该行带有指向URL的链接,URL包含该行中另一列的数据

Php 将按钮添加到HTML表中的一行,该行带有指向URL的链接,URL包含该行中另一列的数据,php,html,Php,Html,我有一个HTML表格,其中的一列在每行末尾包含一个按钮: echo "<td><button type='button' class='btn btn-primary'>View Order </button></td>"; echo“查看顺序”; 如何使此按钮链接到viewOrder.php,并从同一行的第一列传递订单号,例如viewOrder.php?id=echo“View order”; 无法提供更多,因为需要更多代码。 如果您的订单

我有一个HTML表格,其中的一列在每行末尾包含一个按钮:

echo "<td><button type='button' class='btn btn-primary'>View Order </button></td>";
echo“查看顺序”;
如何使此按钮链接到
viewOrder.php
,并从同一行的第一列传递订单号,例如
viewOrder.php?id=

echo“View order”;
无法提供更多,因为需要更多代码。

如果您的订单号是一些具有
id=“orderNumer”
div
span
等,请使用
document.getElementById(“orderNumber”).innerHTML
假设您有一个PHP变量$orderNumber:

echo "<td><button type='button' class='btn btn-primary' onClick='doThing({$orderNumber});'>View Order </button></td>";

由于您的按钮将带您进入一个新页面,并且您正在请求get请求,因此我认为您应该使用链接。您还可以选择设置链接样式,使其看起来像按钮

这样,通过在URL中添加
orderNumber
,可以避免使用java脚本执行get请求

由于您似乎正在使用引导,因此可以使用
btn btn primary
类使链接看起来像一个按钮

试试这个:


echo”“;

什么是“订单号”?请显示更多代码
echo "<td><button type='button' class='btn btn-primary' onClick='doThing({$orderNumber});'>View Order </button></td>";
function doThing(ordernum)
{
    document.location.href = "viewOrder.php?id=" + ordernum;
}
echo "<td><a href="viewOrder.php?id=$ordernumber" class="btn btn-primary">View Order</a></td>";