doubi3929 2018-04-28 19:24
浏览 108
已采纳

如何通过单击按钮将当前PHP文件的值传递给另一个PHP文件?

I'm trying to link one php file to another one. The first file, which is a query result of one mysql command, contains introduction of all the products.

enter image description here

When the "Details" button is clicked, I want the page to be redirected to another php file, which accepts the query result (ID, name) from the first file and output the detailed information.

Now I'm stuck at the "button" step. Could anyone help me to link the two files?

<div><button href = "Product_details.php" type="submit" name="Details" class="btn btn-default">Details</button></div>
  • 写回答

1条回答 默认 最新

  • dongxingdu9594 2018-04-28 19:33
    关注

    you can use the $_GET variable like :

    <div><button href = "Product_details.php?data1=value2&data2=value2" type="submit" name="Details" class="btn btn-default">Details</button></div>
    

    value1 and value2 are supposed as two variables available in the current php file which the button exist named $data1 and $data2

    it's goning to be something like :

    <div><button href = "Product_details.php?data1=<?php echo $data1?>&data2=<?echo $data2?>" type="submit" name="Details" class="btn btn-default">Details</button></div>
    

    and in the Product_details.php , you can get you data as :

    $data1 = $_GET['data1'];
    $data2 = $_GET['data2'];
    
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥15 前后端分离的学习疑问?
  • ¥15 stata实证代码答疑
  • ¥15 MATLAB数据处理插值
  • ¥50 husky+jaco2实现在gazebo与rviz中联合仿真
  • ¥15 dpabi预处理报错:Error using y_ExtractROISignal (line 251)
  • ¥15 在虚拟机中配置flume,无法将slave1节点的文件采集到master节点中
  • ¥15 husky+kinova jaco2 仿真
  • ¥15 zigbee终端设备入网失败
  • ¥15 金融监管系统怎么对7+4机构进行监管的
  • ¥15 硬件IIC从模式的数据发送,中断数据的接收,不能用HAL库(按照时序图)