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 可见光定位matlab仿真
  • ¥15 arduino 四自由度机械臂
  • ¥15 wordpress 产品图片 GIF 没法显示
  • ¥15 求三国群英传pl国战时间的修改方法
  • ¥15 matlab代码代写,需写出详细代码,代价私
  • ¥15 ROS系统搭建请教(跨境电商用途)
  • ¥15 AIC3204的示例代码有吗,想用AIC3204测量血氧,找不到相关的代码。
  • ¥20 CST怎么把天线放在座椅环境中并仿真
  • ¥15 任务A:大数据平台搭建(容器环境)怎么做呢?
  • ¥15 YOLOv8obb获取边框坐标时报错AttributeError: 'NoneType' object has no attribute 'xywhr'