javascript - 选择html表的一些行,并在单击链接时将所选行的一列的值发送到另一个php页面

标签 javascript php jquery html mysql

我需要选择 html 表的某些行,并在单击链接时将所选行的一列的值发送到另一个 php 页面。怎样才能做到呢?

使用表单,我可以将值存储在表单元素数组中,并且可以在单击提交按钮时发送到 php 数组。但在这种情况下它必须通过链接。

<?php 
$query2="select * from products";
$result2=mysqli_query($connection, $query2);
?>
      <table>
    <thead>
        <tr>
        <th><input type="checkbox" id="0" /></th>   
        <th>Item</th>   
        <th>Date</th>   
        <th>Type</th>   
        <th>Price</th>   
        <th>SKU</th>   
        <th>Description</th>   
        </tr>
    </thead>
    <tbody>
<?php
$i=1;
while($row2=mysqli_fetch_array($result2))
{
?>  
        <tr>
            <td><input type="checkbox" id="<?php $i; ?>" name="check['<?php echo $i; ?>']" value="<?php echo $row2['id']; ?>"/></td>
            <td>$row2['item']</td>
            <td>$row2['date']/td>
            <td>$row2['type']</td>
            <td>$row2['price']</td>
            <td>$row2['sku']</td>
            <td>$row2['description']</td>
        </tr>
<?php
$i++;
}
?>
    </tbody>
</table>
<a href="index.php?page=reviewselecteditems">Review Selected Items</a>

我想将所选行的“项目”列值存储在变量中,并且需要将其传递到另一个 php 文件,在该文件中我想从数据库中获取所选项目的所有相关详细信息(如金额、税费等)并显示它在 html 表中。

最佳答案

在 id 属性中设置产品 id,然后单击“审核”按钮,将 GET 方法中的这些 id 发送到下一页,然后用户 $_GET 检索这些 id 并从这些 id 执行用于获取特定产品的 sql 查询

它将重定向类似这样的内容:

http://localhost/yourpage?id=1,2,3

获取此 ID 并分解它们。

关于javascript - 选择html表的一些行,并在单击链接时将所选行的一列的值发送到另一个php页面,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/57200366/

相关文章:

php - 使用 Laravel 任务调度请求 URL

javascript - 如何将 Javascript 库添加到 Angular 4 组件?

javascript - 将 JavaScript 添加到动态(插件生成的)元素

javascript - 根据内容调整 SVG 元素的大小

javascript - 更改父级具有隔离范围的 Angular Directive(指令)上的父级范围变量

javascript - ionic ui-router 解析的结果没有显示在页面中

php - 通过电子邮件发送 div 的内容或屏幕截图

javascript - 数组的 Google Closure Compiler 类型注释

php - 如何使用命令 2 发送推送通知二进制格式

php - Mysql导入导出的sql文件