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

如何通过单击按钮将当前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
    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'];
    
    点赞 评论

相关推荐