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 乌班图ip地址配置及远程SSH
  • ¥15 怎么让点阵屏显示静态爱心,用keiluVision5写出让点阵屏显示静态爱心的代码,越快越好
  • ¥15 PSPICE制作一个加法器
  • ¥15 javaweb项目无法正常跳转
  • ¥15 VMBox虚拟机无法访问
  • ¥15 skd显示找不到头文件
  • ¥15 机器视觉中图片中长度与真实长度的关系
  • ¥15 fastreport table 怎么只让每页的最下面和最顶部有横线
  • ¥15 java 的protected权限 ,问题在注释里
  • ¥15 这个是哪里有问题啊?